Skip to content

Commit

Permalink
Add PrivateDnsTestRunner and replace TestBase (#18202)
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainFanZzz authored May 18, 2022
1 parent afd7508 commit f03530c
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 227 deletions.
47 changes: 21 additions & 26 deletions src/PrivateDns/PrivateDns.Test/ScenarioTests/LinkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,151 +12,146 @@

namespace Microsoft.Azure.Commands.PrivateDns.Test.ScenarioTests
{
using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

public class LinkTests : PrivateDnsTestsBase
public class LinkTests : PrivateDnsTestRunner
{
public XunitTracingInterceptor Logger;

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestLinkCrud()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-LinkCrud");
TestRunner.RunTestScript("Test-LinkCrud");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestLinkCrudWithPiping()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-LinkCrudWithPiping");
TestRunner.RunTestScript("Test-LinkCrudWithPiping");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRegistrationLinkCreate()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-RegistrationLinkCreate");
TestRunner.RunTestScript("Test-RegistrationLinkCreate");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestLinkAlreadyExistsCreateThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-LinkAlreadyExistsCreateThrow");
TestRunner.RunTestScript("Test-LinkAlreadyExistsCreateThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateLinkWithVirtualNetworkObject()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-CreateLinkWithVirtualNetworkObject");
TestRunner.RunTestScript("Test-CreateLinkWithVirtualNetworkObject");
}

[Fact(Skip = "Test framework doesn't support using tokens for multiple tenants at the moment.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateLinkWithRemoteVirtualId()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-CreateLinkWithRemoteVirtualId");
TestRunner.RunTestScript("Test-CreateLinkWithRemoteVirtualId");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkRegistrationStatusWithPiping()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkRegistrationStatusWithPiping");
TestRunner.RunTestScript("Test-UpdateLinkRegistrationStatusWithPiping");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkRegistrationStatusWithPipingResourceId()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkRegistrationStatusWithResourceId");
TestRunner.RunTestScript("Test-UpdateLinkRegistrationStatusWithResourceId");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkWithEtagMismatchThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkWithEtagMismatchThrow");
TestRunner.RunTestScript("Test-UpdateLinkWithEtagMismatchThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDeleteLinkWithResourceId()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-DeleteLinkWithResourceId");
TestRunner.RunTestScript("Test-DeleteLinkWithResourceId");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkWithEtagMismatchOverwrite()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkWithEtagMismatchOverwrite");
TestRunner.RunTestScript("Test-UpdateLinkWithEtagMismatchOverwrite");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkZoneNotExistsThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkZoneNotExistsThrow");
TestRunner.RunTestScript("Test-UpdateLinkZoneNotExistsThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkLinkNotExistsThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkLinkNotExistsThrow");
TestRunner.RunTestScript("Test-UpdateLinkLinkNotExistsThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkWithNoChangesShouldNotThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkWithNoChangesShouldNotThrow");
TestRunner.RunTestScript("Test-UpdateLinkWithNoChangesShouldNotThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLinkZoneNotExistsThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-GetLinkZoneNotExistsThrow");
TestRunner.RunTestScript("Test-GetLinkZoneNotExistsThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLinkLinkNotExistsThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-GetLinkLinkNotExistsThrow");
TestRunner.RunTestScript("Test-GetLinkLinkNotExistsThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveLinkZoneNotExistsShouldNotThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-RemoveLinkZoneNotExistsShouldNotThrow");
TestRunner.RunTestScript("Test-RemoveLinkZoneNotExistsShouldNotThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveLinkLinkNotExistsShouldNotThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-RemoveLinkLinkNotExistsShouldNotThrow");
TestRunner.RunTestScript("Test-RemoveLinkLinkNotExistsShouldNotThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestListLinks()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-ListLinks");
TestRunner.RunTestScript("Test-ListLinks");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// ----------------------------------------------------------------------------------
//
// 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.PrivateDns.Test.ScenarioTests
{
public class PrivateDnsTestRunner
{
protected readonly ITestRunner TestRunner;

protected PrivateDnsTestRunner(ITestOutputHelper output)
{
TestRunner = TestManager.CreateInstance(output)
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
.WithProjectSubfolderForTests("ScenarioTests")
.WithCommonPsScripts(new[]
{
@"Common.ps1",
@"../AzureRM.Resources.ps1"
})
.WithNewRmModules(helper => new[]
{
helper.RMProfileModule,
helper.GetRMModulePath("Az.PrivateDns.psd1"),
helper.GetRMModulePath("Az.Network.psd1")
})
.WithNewRecordMatcherArguments(
userAgentsToIgnore: new Dictionary<string, string>
{
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
},
resourceProviders: new Dictionary<string, string>
{
{"Microsoft.Resources", null},
{"Microsoft.Features", null},
{"Microsoft.Authorization", null},
{"Microsoft.Network", null}
}
)
.Build();
}
}
}
142 changes: 0 additions & 142 deletions src/PrivateDns/PrivateDns.Test/ScenarioTests/PrivateDnsTestsBase.cs

This file was deleted.

Loading

0 comments on commit f03530c

Please sign in to comment.