Skip to content

Add DataShareTestRunner to replace TestController #18115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/DataShare/DataShare.Test/ScenarioTests/AccountTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

public class AccountTests
public class AccountTests : DataShareTestRunner
{
private readonly ServiceManagement.Common.Models.XunitTracingInterceptor logger;

public AccountTests(Xunit.Abstractions.ITestOutputHelper output)
public AccountTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAccountCrud()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-AccountCrud");
TestRunner.RunTestScript("Test-AccountCrud");
}
}
}
10 changes: 3 additions & 7 deletions src/DataShare/DataShare.Test/ScenarioTests/AdlsGen1Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

public class AdlsGen1Tests
public class AdlsGen1Tests : DataShareTestRunner
{
private readonly ServiceManagement.Common.Models.XunitTracingInterceptor logger;

public AdlsGen1Tests(Xunit.Abstractions.ITestOutputHelper output)
public AdlsGen1Tests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAdlsGen1Crud()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-AdlsGen1Crud");
TestRunner.RunTestScript("Test-AdlsGen1Crud");
}
}
}
10 changes: 3 additions & 7 deletions src/DataShare/DataShare.Test/ScenarioTests/AdlsGen2Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

public class AdlsGen2Tests
public class AdlsGen2Tests : DataShareTestRunner
{
private readonly ServiceManagement.Common.Models.XunitTracingInterceptor logger;

public AdlsGen2Tests(Xunit.Abstractions.ITestOutputHelper output)
public AdlsGen2Tests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAdlsGen2Crud()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-AdlsGen2Crud");
TestRunner.RunTestScript("Test-AdlsGen2Crud");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

public class ConsumerInvitationTests
public class ConsumerInvitationTests : DataShareTestRunner
{
private readonly ServiceManagement.Common.Models.XunitTracingInterceptor logger;

public ConsumerInvitationTests(Xunit.Abstractions.ITestOutputHelper output)
public ConsumerInvitationTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestConsumerInvitationCrud()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-ConsumerInvitationCrud");
TestRunner.RunTestScript("Test-ConsumerInvitationCrud");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// http://www.apache.org/licenses/LICENSE-2.0
// ----------------------------------------------------------------------------------
//
// 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.
Expand All @@ -11,21 +17,17 @@ namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

public class ConsumerSourceDataSetsTests
public class ConsumerSourceDataSetsTests : DataShareTestRunner
{
private readonly ServiceManagement.Common.Models.XunitTracingInterceptor logger;

public ConsumerSourceDataSetsTests(Xunit.Abstractions.ITestOutputHelper output)
public ConsumerSourceDataSetsTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSourceDataSetsCrud()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-SourceDataSetsCrud");
TestRunner.RunTestScript("Test-SourceDataSetsCrud");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,24 @@ namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

public class DataSetMappingTests
public class DataSetMappingTests : DataShareTestRunner
{
private readonly ServiceManagement.Common.Models.XunitTracingInterceptor logger;

public DataSetMappingTests(Xunit.Abstractions.ITestOutputHelper output)
public DataSetMappingTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestBlobDataSetMappingCrud()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-BlobDataSetMappingCrud");
TestRunner.RunTestScript("Test-BlobDataSetMappingCrud");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAdlsGen2DataSetMappingCrud()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-AdlsGen2DataSetMappingCrud");
TestRunner.RunTestScript("Test-AdlsGen2DataSetMappingCrud");
}
}
}
10 changes: 3 additions & 7 deletions src/DataShare/DataShare.Test/ScenarioTests/DataSetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

public class DataSetTests
public class DataSetTests : DataShareTestRunner
{
private readonly ServiceManagement.Common.Models.XunitTracingInterceptor logger;

public DataSetTests(Xunit.Abstractions.ITestOutputHelper output)
public DataSetTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDataSetCrud()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-DataSetCrud");
TestRunner.RunTestScript("Test-DataSetCrud");
}
}
}
56 changes: 56 additions & 0 deletions src/DataShare/DataShare.Test/ScenarioTests/DataShareTestRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
{
using System.Collections.Generic;
using Microsoft.Azure.Commands.TestFx;
using Xunit.Abstractions;

public class DataShareTestRunner
{
protected readonly ITestRunner TestRunner;

protected DataShareTestRunner(ITestOutputHelper output)
{
TestRunner = TestFx.TestManager.CreateInstance(output)
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
.WithProjectSubfolderForTests("ScenarioTests")
.WithCommonPsScripts(new[]
{
@"Common.ps1",
@"../AzureRM.Resources.ps1"
})
.WithNewRmModules(helper => new[]
{
helper.RMProfileModule,
helper.GetRMModulePath("Az.DataShare.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.Compute", null}
}
)
.Build();
}
}
}
26 changes: 18 additions & 8 deletions src/DataShare/DataShare.Test/ScenarioTests/InvitationTests.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

public class InvitationTests
public class InvitationTests : DataShareTestRunner
{
private readonly ServiceManagement.Common.Models.XunitTracingInterceptor logger;

public InvitationTests(Xunit.Abstractions.ITestOutputHelper output)
public InvitationTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestInvitationCrud()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-InvitationCrud");
TestRunner.RunTestScript("Test-InvitationCrud");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,24 @@ namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

public class ProviderShareSubscriptionTests
public class ProviderShareSubscriptionTests : DataShareTestRunner
{
private readonly ServiceManagement.Common.Models.XunitTracingInterceptor logger;

public ProviderShareSubscriptionTests(Xunit.Abstractions.ITestOutputHelper output)
public ProviderShareSubscriptionTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestProviderShareSubscriptionGrantAndRevoke()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-ProviderShareSubscriptionGrantAndRevoke");
TestRunner.RunTestScript("Test-ProviderShareSubscriptionGrantAndRevoke");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestProviderShareSubscriptionGet()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-ProviderShareSubscriptionGet");
TestRunner.RunTestScript("Test-ProviderShareSubscriptionGet");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

namespace Microsoft.Azure.Commands.DataShare.Test.ScenarioTests.ScenarioTest
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

public class ShareSubscriptionTests
public class ShareSubscriptionTests : DataShareTestRunner
{
private readonly ServiceManagement.Common.Models.XunitTracingInterceptor logger;

public ShareSubscriptionTests(Xunit.Abstractions.ITestOutputHelper output)
public ShareSubscriptionTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestShareSubscriptionCrud()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-ShareSubscriptionCrud");
TestRunner.RunTestScript("Test-ShareSubscriptionCrud");
}
}
}
Loading