Skip to content

Commit

Permalink
Add RelayTestRunner and replace Controller (#18223)
Browse files Browse the repository at this point in the history
* Add RelayTestRunner and replace Controller

* update userAgentsToIgnore
  • Loading branch information
CaptainFanZzz authored May 20, 2022
1 parent dfd0739 commit 09f4176
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 183 deletions.
12 changes: 3 additions & 9 deletions src/Relay/Relay.Test/ScenarioTests/HybridConnectionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,19 @@
namespace Microsoft.Azure.Commands.Relay.Test.ScenarioTests
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using ServiceManagement.Common.Models;
using Xunit;
using Xunit.Abstractions;
public class HybridConnectionsTests : RMTestBase
public class HybridConnectionsTests : RelayTestRunner
{
public XunitTracingInterceptor _logger;

public HybridConnectionsTests(Xunit.Abstractions.ITestOutputHelper output)
public HybridConnectionsTests(ITestOutputHelper output) : base(output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void HybridConnectionsCRUD()
{
RelayController.NewInstance.RunPsTest(_logger, "HybridConnectionsTests");
TestRunner.RunTestScript("HybridConnectionsTests");
}
}
}
12 changes: 3 additions & 9 deletions src/Relay/Relay.Test/ScenarioTests/Namespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,19 @@
namespace Microsoft.Azure.Commands.Relay.Test.ScenarioTests
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using ServiceManagement.Common.Models;
using Xunit;
using Xunit.Abstractions;
public class RelayNamespaceTests : RMTestBase
public class RelayNamespaceTests : RelayTestRunner
{
public XunitTracingInterceptor _logger;

public RelayNamespaceTests(Xunit.Abstractions.ITestOutputHelper output)
public RelayNamespaceTests(ITestOutputHelper output) : base(output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RelayNamespaceCRUD()
{
RelayController.NewInstance.RunPsTest(_logger, "RelayNamespaceTests");
TestRunner.RunTestScript("RelayNamespaceTests");
}
}
}
12 changes: 3 additions & 9 deletions src/Relay/Relay.Test/ScenarioTests/OperationsListTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,19 @@
namespace Microsoft.Azure.Commands.Relay.Test.ScenarioTests
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using ServiceManagement.Common.Models;
using Xunit;
using Xunit.Abstractions;
public class OperationsListTest : RMTestBase
public class OperationsListTest : RelayTestRunner
{
public XunitTracingInterceptor _logger;

public OperationsListTest(ITestOutputHelper output)
public OperationsListTest(ITestOutputHelper output) : base(output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void Operations()
{
RelayController.NewInstance.RunPsTest(_logger, "OperationsListTest");
TestRunner.RunTestScript("OperationsListTest");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,19 @@
namespace Microsoft.Azure.Commands.Relay.Test.ScenarioTests
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using ServiceManagement.Common.Models;
using Xunit;
using Xunit.Abstractions;
public class RelayAuthorizationRulesTests : RMTestBase
public class RelayAuthorizationRulesTests : RelayTestRunner
{
public XunitTracingInterceptor _logger;

public RelayAuthorizationRulesTests(ITestOutputHelper output)
public RelayAuthorizationRulesTests(ITestOutputHelper output) : base(output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RelayAuthorizationRulesTestsCRUD()
{
RelayController.NewInstance.RunPsTest(_logger, "RelayAuthTests");
TestRunner.RunTestScript("RelayAuthTests");
}
}
}
129 changes: 0 additions & 129 deletions src/Relay/Relay.Test/ScenarioTests/RelayController.cs

This file was deleted.

54 changes: 54 additions & 0 deletions src/Relay/Relay.Test/ScenarioTests/RelayTestRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System.Collections.Generic;
using Microsoft.Azure.Commands.TestFx;
using Xunit.Abstractions;

namespace Microsoft.Azure.Commands.Relay.Test.ScenarioTests
{
public class RelayTestRunner
{
protected readonly ITestRunner TestRunner;

protected RelayTestRunner(ITestOutputHelper output)
{
TestRunner = TestManager.CreateInstance(output)
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
.WithProjectSubfolderForTests("ScenarioTests")
.WithCommonPsScripts(new[]
{
@"../AzureRM.Resources.ps1"
})
.WithNewRmModules(helper => new[]
{
helper.RMProfileModule,
helper.GetRMModulePath("Az.Relay.psd1")
})
.WithNewRecordMatcherArguments(
userAgentsToIgnore: new Dictionary<string, string>
{
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-07-01"}
},
resourceProviders: new Dictionary<string, string>
{
{"Microsoft.Resources", null},
{"Microsoft.Features", null},
{"Microsoft.Authorization", null}
}
)
.Build();
}
}
}
12 changes: 3 additions & 9 deletions src/Relay/Relay.Test/ScenarioTests/TestAzureRmRelayNameTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,19 @@
namespace Microsoft.Azure.Commands.Relay.Test.ScenarioTests
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using ServiceManagement.Common.Models;
using Xunit;
using Xunit.Abstractions;
public class TestAzureRmRelayNameTests : RMTestBase
public class TestAzureRmRelayNameTests : RelayTestRunner
{
public XunitTracingInterceptor _logger;

public TestAzureRmRelayNameTests(ITestOutputHelper output)
public TestAzureRmRelayNameTests(ITestOutputHelper output) : base(output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void CheckNameAvailability()
{
RelayController.NewInstance.RunPsTest(_logger, "TestAzureRmRelayNameTests");
TestRunner.RunTestScript("TestAzureRmRelayNameTests");
}
}
}
12 changes: 3 additions & 9 deletions src/Relay/Relay.Test/ScenarioTests/WcfRelayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,19 @@
namespace Microsoft.Azure.Commands.Relay.Test.ScenarioTests
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using ServiceManagement.Common.Models;
using Xunit;
using Xunit.Abstractions;
public class WcfRelayTests : RMTestBase
public class WcfRelayTests : RelayTestRunner
{
public XunitTracingInterceptor _logger;

public WcfRelayTests(ITestOutputHelper output)
public WcfRelayTests(ITestOutputHelper output) : base(output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void WcfRelayCRUD()
{
RelayController.NewInstance.RunPsTest(_logger, "WcfRelayTests");
TestRunner.RunTestScript("WcfRelayTests");
}
}
}

0 comments on commit 09f4176

Please sign in to comment.