Skip to content

Commit

Permalink
Add RedisCacheTestRunner and replace Controller (#18222)
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainFanZzz authored May 18, 2022
1 parent fbaa9e8 commit afd7508
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 141 deletions.
122 changes: 0 additions & 122 deletions src/RedisCache/RedisCache.Test/ScenarioTests/RedisCacheController.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// ----------------------------------------------------------------------------------
//
// 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.RedisCache.Test.ScenarioTests
{
public class RedisCacheTestRunner
{
protected readonly ITestRunner TestRunner;

protected RedisCacheTestRunner(ITestOutputHelper output)
{
TestRunner = TestManager.CreateInstance(output)
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
.WithProjectSubfolderForTests("ScenarioTests")
.WithCommonPsScripts(new[]
{
@"../AzureRM.Storage.ps1",
@"../AzureRM.Resources.ps1"
})
.WithNewRmModules(helper => new[]
{
helper.RMProfileModule,
helper.GetRMModulePath("Az.RedisCache.psd1")
})
.WithNewRecordMatcherArguments(
userAgentsToIgnore: new Dictionary<string, string>(),
resourceProviders: new Dictionary<string, string>
{
{"Microsoft.Resources", null},
{"Microsoft.Features", null},
{"Microsoft.Authorization", null}
}
)
.Build();
}
}
}
32 changes: 13 additions & 19 deletions src/RedisCache/RedisCache.Test/ScenarioTests/RedisCacheTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,61 +15,55 @@
namespace Microsoft.Azure.Commands.RedisCache.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 RedisCacheTests : RMTestBase
public class RedisCacheTests : RedisCacheTestRunner
{
public XunitTracingInterceptor _logger;

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRedisCache()
{
RedisCacheController.NewInstance.RunPowerShellTest(_logger, "Test-RedisCache");
TestRunner.RunTestScript("Test-RedisCache");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetNonExistingRedisCacheTest()
{
RedisCacheController.NewInstance.RunPowerShellTest(_logger, "Test-SetNonExistingRedisCacheTest");
TestRunner.RunTestScript("Test-SetNonExistingRedisCacheTest");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRedisCachePipeline()
{
RedisCacheController.NewInstance.RunPowerShellTest(_logger, "Test-RedisCachePipeline");
TestRunner.RunTestScript("Test-RedisCachePipeline");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRedisCacheClustering()
{
RedisCacheController.NewInstance.RunPowerShellTest(_logger, "Test-RedisCacheClustering");
TestRunner.RunTestScript("Test-RedisCacheClustering");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRedisCachePatchSchedules()
{
RedisCacheController.NewInstance.RunPowerShellTest(_logger, "Test-RedisCachePatchSchedules");
TestRunner.RunTestScript("Test-RedisCachePatchSchedules");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestImportExportReboot()
{
RedisCacheController.NewInstance.RunPowerShellTest(_logger, "Test-ImportExportReboot");
TestRunner.RunTestScript("Test-ImportExportReboot");
}

#if NETSTANDARD
Expand All @@ -80,35 +74,35 @@ public void TestImportExportReboot()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDiagnosticOperations()
{
RedisCacheController.NewInstance.RunPowerShellTest(_logger, "Test-DiagnosticOperations");
TestRunner.RunTestScript("Test-DiagnosticOperations");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGeoReplication()
{
RedisCacheController.NewInstance.RunPowerShellTest(_logger, "Test-GeoReplication");
TestRunner.RunTestScript("Test-GeoReplication");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestFirewallRule()
{
RedisCacheController.NewInstance.RunPowerShellTest(_logger, "Test-FirewallRule");
TestRunner.RunTestScript("Test-FirewallRule");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestZones()
{
RedisCacheController.NewInstance.RunPowerShellTest(_logger, "Test-Zones");
TestRunner.RunTestScript("Test-Zones");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestManagedIdentity()
{
RedisCacheController.NewInstance.RunPowerShellTest(_logger, "Test-ManagedIdentity");
TestRunner.RunTestScript("Test-ManagedIdentity");
}
}
}

0 comments on commit afd7508

Please sign in to comment.