Skip to content

Commit a88dbd3

Browse files
CaptainFanZzzZiyue Zheng
andauthored
Add AnalysisServicesTestRunner and replace AsTestsBase (Azure#18056)
* Add AnalysisServicesTestRunner and replace AsTestsBase * Add AnalysisServicesTestRunner and replace AsTestsBase * update Inmemorytest Co-authored-by: Ziyue Zheng <[email protected]>
1 parent 8ea8cca commit a88dbd3

File tree

4 files changed

+70
-161
lines changed

4 files changed

+70
-161
lines changed

src/AnalysisServices/AnalysisServices.Test/InMemoryTests/DataPlaneCommandTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
using System.Threading.Tasks;
2222
using Microsoft.Azure.Commands.AnalysisServices.Dataplane;
2323
using Microsoft.Azure.Commands.AnalysisServices.Dataplane.Models;
24-
using Microsoft.Azure.Commands.AnalysisServices.Test.ScenarioTests;
2524
using Microsoft.Azure.Commands.Profile.Models.Core;
2625
using Microsoft.Azure.ServiceManagement.Common.Models;
2726
using Microsoft.WindowsAzure.Commands.ScenarioTest;
@@ -31,12 +30,12 @@
3130
using Xunit.Abstractions;
3231
using System.Collections.Generic;
3332
using System.Net.Http.Headers;
34-
using Newtonsoft.Json;
3533
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
34+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
3635

3736
namespace Microsoft.Azure.Commands.AnalysisServices.Test.InMemoryTests
3837
{
39-
public class DataPlaneCommandTests : AsTestsBase
38+
public class DataPlaneCommandTests : RMTestBase
4039
{
4140
private const string testInstance = "asazure://westcentralus.asazure.windows.net/testserver";
4241

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Collections.Generic;
16+
using Microsoft.Azure.Commands.TestFx;
17+
using Xunit.Abstractions;
18+
19+
namespace Microsoft.Azure.Commands.AnalysisServices.Test.ScenarioTests
20+
{
21+
public class AnalysisServicesTestRunner
22+
{
23+
protected readonly ITestRunner TestRunner;
24+
25+
protected AnalysisServicesTestRunner(ITestOutputHelper output)
26+
{
27+
TestRunner = TestManager.CreateInstance(output)
28+
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
29+
.WithProjectSubfolderForTests("ScenarioTests")
30+
.WithCommonPsScripts(new[]
31+
{
32+
@"Common.ps1",
33+
@"../AzureRM.Resources.ps1"
34+
})
35+
.WithNewRmModules(helper => new[]
36+
{
37+
helper.RMProfileModule,
38+
helper.GetRMModulePath("Az.AnalysisServices.psd1")
39+
})
40+
.WithNewRecordMatcherArguments(
41+
userAgentsToIgnore: new Dictionary<string, string>
42+
{
43+
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
44+
},
45+
resourceProviders: new Dictionary<string, string>
46+
{
47+
{"Microsoft.Resources", null},
48+
{"Microsoft.Features", null},
49+
{"Microsoft.Authorization", null}
50+
}
51+
)
52+
.Build();
53+
}
54+
}
55+
}

src/AnalysisServices/AnalysisServices.Test/ScenarioTests/AsTests.cs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,91 +18,87 @@ namespace Microsoft.Azure.Commands.AnalysisServices.Test.ScenarioTests
1818
using ServiceManagement.Common.Models;
1919
using Xunit;
2020

21-
public class AsTests : AsTestsBase
21+
public class AsTests : AnalysisServicesTestRunner
2222
{
23-
public XunitTracingInterceptor _logger;
24-
25-
public AsTests(Xunit.Abstractions.ITestOutputHelper output)
23+
public AsTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2624
{
27-
_logger = new XunitTracingInterceptor(output);
28-
XunitTracingInterceptor.AddToContext(_logger);
2925
}
3026

3127
[Fact]
3228
[Trait(Category.AcceptanceType, Category.CheckIn)]
3329
public void TestAnalysisServicesServer()
3430
{
35-
NewInstance.RunPsTest(_logger, "Test-AnalysisServicesServer");
31+
TestRunner.RunTestScript("Test-AnalysisServicesServer");
3632
}
3733

3834
[Fact]
3935
[Trait(Category.AcceptanceType, Category.CheckIn)]
4036
public void TestAnalysisServicesServerScaleUpDown()
4137
{
42-
NewInstance.RunPsTest(_logger, "Test-AnalysisServicesServerScaleUpDown");
38+
TestRunner.RunTestScript("Test-AnalysisServicesServerScaleUpDown");
4339
}
4440

4541
[Fact]
4642
[Trait(Category.AcceptanceType, Category.CheckIn)]
4743
public void TestAnalysisServicesServerScaleOutIn()
4844
{
49-
NewInstance.RunPsTest(_logger, "Test-AnalysisServicesServerScaleOutIn");
45+
TestRunner.RunTestScript("Test-AnalysisServicesServerScaleOutIn");
5046
}
5147

5248
[Fact]
5349
[Trait(Category.AcceptanceType, Category.CheckIn)]
5450
public void TestAnalysisServicesServerFirewall()
5551
{
56-
NewInstance.RunPsTest(_logger, "Test-AnalysisServicesServerFirewall");
52+
TestRunner.RunTestScript("Test-AnalysisServicesServerFirewall");
5753
}
5854

5955
[Fact]
6056
[Trait(Category.RunType, Category.LiveOnly)]
6157
public void TestAnalysisServicesServerDisableBackup()
6258
{
63-
NewInstance.RunPsTest(_logger, "Test-AnalysisServicesServerDisableBackup");
59+
TestRunner.RunTestScript("Test-AnalysisServicesServerDisableBackup");
6460
}
6561

6662
[Fact]
6763
[Trait(Category.AcceptanceType, Category.CheckIn)]
6864
public void TestNegativeAnalysisServicesServer()
6965
{
70-
NewInstance.RunPsTest(_logger, "Test-NegativeAnalysisServicesServer");
66+
TestRunner.RunTestScript("Test-NegativeAnalysisServicesServer");
7167
}
7268

7369
[Fact]
7470
[Trait(Category.RunType, Category.LiveOnly)]
7571
public void TestAnalysisServicesServerLogExport()
7672
{
77-
NewInstance.RunPsTest(_logger, "Test-AnalysisServicesServerLogExport");
73+
TestRunner.RunTestScript("Test-AnalysisServicesServerLogExport");
7874
}
7975

8076
[Fact]
8177
[Trait(Category.RunType, Category.LiveOnly)]
8278
public void TestAnalysisServicesServerRestart()
8379
{
84-
NewInstance.RunPsTest(_logger, "Test-AnalysisServicesServerRestart");
80+
TestRunner.RunTestScript("Test-AnalysisServicesServerRestart");
8581
}
8682

8783
[Fact]
8884
[Trait(Category.RunType, Category.LiveOnly)]
8985
public void TestAnalysisServicesServerSynchronizeSingle()
9086
{
91-
NewInstance.RunPsTest(_logger, "Test-AnalysisServicesServerSynchronizeSingle");
87+
TestRunner.RunTestScript("Test-AnalysisServicesServerSynchronizeSingle");
9288
}
9389

9490
[Fact]
9591
[Trait(Category.RunType, Category.LiveOnly)]
9692
public void TestAnalysisServicesServerLoginWithSPN()
9793
{
98-
NewInstance.RunPsTest(_logger, "Test-AnalysisServicesServerLoginWithSPN");
94+
TestRunner.RunTestScript("Test-AnalysisServicesServerLoginWithSPN");
9995
}
10096

10197
[Fact]
10298
[Trait(Category.RunType, Category.LiveOnly)]
10399
public void TestAnalysisServicesServerGateway()
104100
{
105-
NewInstance.RunPsTest(_logger, "Test-AnalysisServicesServerGateway");
101+
TestRunner.RunTestScript("Test-AnalysisServicesServerGateway");
106102
}
107103

108104
}

src/AnalysisServices/AnalysisServices.Test/ScenarioTests/AsTestsBase.cs

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)