-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/override setting with env vars (#16)
* repare a basic implementation of core functionality #1 Author: Alaksiej Mialeška <[email protected]> * replace GetText() with property. make constants internal * fix logging and settings resources. Add some tests * Fix ConditionalWait and tests * add general tests and some documentation. Enhanced Startup for flexibility * fix review comments in LoggerConfiguration and Element * removed internal access modifiers * Set up CI with Azure Pipelines [skip ci] * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * fix webDriverVersion for tests * fix WebDriverVersion dowloaded for tests at azure pipeline. closes #3 * Update azure-pipelines.yml for Azure Pipelines * fix webDriverVersion * fix yml file * Add tests for WinAppDriver and ElementFactory to resolve #5. Related to #6. Corrected Element's public interface * Update azure-pipelines.yml for Azure Pipelines use WinAppDriver task * Update azure-pipelines.yml for Azure Pipelines * replace calc application * Fixed ElementFactoryTests for new application * Feature/abstract application manager (#8) * Extract abstract ApplicationManager from WIndowsApp/ApplicationManager * reworked ApplicationManager for chrome app tests * Enhanced abstract ApplicationManager, add ability to provide custom dependencies. Create tests to ensure that ApplicationManager could have custom dependencies registered in container. * #11 added tests to check overriden settings * #15 added test for ovveriding config with env vars * #15 added fix for Azure * #15 added possibility to get Dictionary from JsonFile with overriden values with Env variables * #15 renamed some method * #15 removed Parallelizable for EnvConfigurationTests removed throw exception in IsValuePresent * #15 added debug test * #15 removed debug test * #15 added string.Empty
- Loading branch information
Showing
4 changed files
with
136 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
....Selenium.Core/tests/Aquality.Selenium.Core.Tests/Configurations/EnvConfigurationTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using Aquality.Selenium.Core.Configurations; | ||
using NUnit.Framework; | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Aquality.Selenium.Core.Tests.Configurations | ||
{ | ||
[Parallelizable(ParallelScope.None)] | ||
public class EnvConfigurationTests : TestWithoutApplication | ||
{ | ||
private const string ProfileVariableName = "profile"; | ||
private const string ProfileName = "custom"; | ||
|
||
[SetUp] | ||
public new void SetUp() | ||
{ | ||
Environment.SetEnvironmentVariable(ProfileVariableName, ProfileName); | ||
} | ||
|
||
[TearDown] | ||
public void CleanUp() | ||
{ | ||
Environment.SetEnvironmentVariable(ProfileVariableName, null); | ||
} | ||
|
||
[Test] | ||
public void Should_BePossible_ToOverrideTimeouts_WithEnvVariables() | ||
{ | ||
const string testValue = "1000"; | ||
var expectedValueSec = TimeSpan.FromSeconds(1000); | ||
var expectedValueMillis = TimeSpan.FromMilliseconds(1000); | ||
const string messageTmp = "{0} timeout should be overridden with env variable"; | ||
Environment.SetEnvironmentVariable("timeouts.timeoutImplicit", testValue); | ||
Environment.SetEnvironmentVariable("timeouts.timeoutCondition", testValue); | ||
Environment.SetEnvironmentVariable("timeouts.timeoutPollingInterval", testValue); | ||
Environment.SetEnvironmentVariable("timeouts.timeoutCommand", testValue); | ||
base.SetUp(); | ||
|
||
var config = ServiceProvider.GetService<ITimeoutConfiguration>(); | ||
Assert.Multiple(() => | ||
{ | ||
Assert.AreEqual(expectedValueSec, config.Command, string.Format(messageTmp, "Command")); | ||
Assert.AreEqual(expectedValueSec, config.Condition, string.Format(messageTmp, "Condition")); | ||
Assert.AreEqual(expectedValueSec, config.Implicit, string.Format(messageTmp, "Implicit")); | ||
Assert.AreEqual(expectedValueMillis, config.PollingInterval, string.Format(messageTmp, "PollingInterval")); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void Should_BePossible_ToOverrideRetryConfig_WithEnvVariables() | ||
{ | ||
const string testValue = "1000"; | ||
var expectedInterval = TimeSpan.FromMilliseconds(1000); | ||
const int expectedNumber = 1000; | ||
const string messageTmp = "Retry value '{0}' should be overridden with env variable"; | ||
Environment.SetEnvironmentVariable("retry.number", testValue); | ||
Environment.SetEnvironmentVariable("retry.pollingInterval", testValue); | ||
base.SetUp(); | ||
|
||
var config = ServiceProvider.GetService<IRetryConfiguration>(); | ||
Assert.Multiple(() => | ||
{ | ||
Assert.AreEqual(expectedInterval, config.PollingInterval, string.Format(messageTmp, "PollingInterval")); | ||
Assert.AreEqual(expectedNumber, config.Number, string.Format(messageTmp, "Number")); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void Should_BePossible_ToOverrideLoggerConfig_WithEnvVariables() | ||
{ | ||
const string testValue = "testLang"; | ||
Environment.SetEnvironmentVariable("logger.language", testValue); | ||
base.SetUp(); | ||
|
||
var config = ServiceProvider.GetService<ILoggerConfiguration>(); | ||
Assert.AreEqual(testValue, config.Language, "Logger language value should be overridden with env variable"); | ||
} | ||
} | ||
} |