Skip to content

Commit

Permalink
feat(test): Adding tests to ensure that the test mode values are not …
Browse files Browse the repository at this point in the history
…changed (#12481)
  • Loading branch information
vinagesh authored Jun 3, 2020
1 parent 55fce02 commit b7bdeb9
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.IO;
using System.Reflection;
using Azure.Core.TestFramework;
using FluentAssertions;
using Microsoft.Extensions.Configuration;
using NUnit.Framework;

namespace Azure.DigitalTwins.Core.Tests
{
[Category("Unit")]
[Parallelizable(ParallelScope.All)]
public class EnsureCorrectTestMode
{
[Test]
// The PR tests use the value in the common.config.json to determine the mode to run the tests.
// This test ensures that the value in common.config.json is not changed.
public void CommonConfig_SetTo_PlaybackMode()
{
// arrange
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
var uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
string workingDirectory = Path.GetDirectoryName(path);
string testSettingsCommonPath = Path.Combine(
workingDirectory,
"config",
"common.config.json");

var testsSettingsConfigBuilder = new ConfigurationBuilder();
testsSettingsConfigBuilder.AddJsonFile(testSettingsCommonPath);

IConfiguration config = testsSettingsConfigBuilder.Build();

// act
var testSettings = config.Get<TestSettings>();

// assert
testSettings.TestMode.Should().Be(RecordedTestMode.Playback, "The PR pipeline should always run the e2e tests in the playback mode so the value of TestMode should not be changed in the common.config.json file.");
}
}
}

0 comments on commit b7bdeb9

Please sign in to comment.