Skip to content
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

feat(test): Adding tests to ensure that the test mode values are not changed #12481

Merged
merged 1 commit into from
Jun 3, 2020
Merged
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
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.");
}
}
}