public static void AssemblyInitialize(TestContext context) { string url = Convert.ToString(context.Properties["SiteUrl"]); RunSettingsHelper.ReadRunSettings(context); report = new HtmlReport("Selenium Tests", RunSettingsHelper.SiteUrl, "", "Google Chrome", RunSettingsHelper.ScreenshotPath); report.StartReport(); _testContext = context; }
public void RunSettingsHelperShouldNotThrowExceptionOnBadXml() { string settingsXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings"; RunSettingsHelper.ReadRunSettings(settingsXml); AssertDefaultValues(); }
public void RunSettingsHelperShouldNotThrowExceptionOnBadXml() { string settingsXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings"; RunSettingsHelper.ReadRunSettings(settingsXml); // Default values must be used Assert.False(RunSettingsHelper.DisableAppDomain); Assert.False(RunSettingsHelper.DisableParallelization); }
public void RunSettingsHelperShouldUseDefaultValuesInCaseOfBadXml() { string settingsXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> Random Text <DisableParallelization>true</DisableParallelization> </RunConfiguration> </RunSettings>"; RunSettingsHelper.ReadRunSettings(settingsXml); // Allow value to be read even after unexpected element body Assert.True(RunSettingsHelper.DisableParallelization); }
public void RunSettingsHelperShouldReadValuesCorrectly(bool disableAppDomain, bool disableParallelization) { string settingsXml = $@"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> <DisableAppDomain>{disableAppDomain.ToString().ToLowerInvariant()}</DisableAppDomain> <DisableParallelization>{disableParallelization.ToString().ToLowerInvariant()}</DisableParallelization> </RunConfiguration> </RunSettings>"; RunSettingsHelper.ReadRunSettings(settingsXml); // Correct values must be sets Assert.Equal(disableAppDomain, RunSettingsHelper.DisableAppDomain); Assert.Equal(disableParallelization, RunSettingsHelper.DisableParallelization); }
public void RunSettingsHelperShouldNotThrowExceptionOnInvalidValuesForElements() { string settingsXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> <DisableAppDomain>1234</DisableAppDomain> <DisableParallelization>smfhekhgekr</DisableParallelization> </RunConfiguration> </RunSettings>"; RunSettingsHelper.ReadRunSettings(settingsXml); // Default values must be used Assert.False(RunSettingsHelper.DisableAppDomain); Assert.False(RunSettingsHelper.DisableParallelization); }
public void RunSettingsHelperShouldNotThrowExceptionOnInvalidValuesForElements() { string settingsXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> <DisableAppDomain>1234</DisableAppDomain> <DisableParallelization>smfhekhgekr</DisableParallelization> <DesignMode>3245sax</DesignMode> <CollectSourceInformation>1234blah</CollectSourceInformation> <NoAutoReporters>1x3_5f8g0</NoAutoReporters> </RunConfiguration> </RunSettings>"; RunSettingsHelper.ReadRunSettings(settingsXml); AssertDefaultValues(); }
public void RunSettingsHelperShouldUseDefaultValuesInCaseOfBadXml() { string settingsXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> Random Text <DisableParallelization>true</DisableParallelization> </RunConfiguration> </RunSettings>"; RunSettingsHelper.ReadRunSettings(settingsXml); // Default value must be used for DisableAppDomain Assert.False(RunSettingsHelper.DisableAppDomain); // DisableParallelization can be set Assert.True(RunSettingsHelper.DisableParallelization); }
public void RunSettingsHelperShouldUseDefaultValuesInCaseOfIncorrectSchemaAndIgnoreAttributes() { string settingsXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> <OuterElement> <DisableParallelization>true</DisableParallelization> </OuterElement> <DisableAppDomain value=""false"">true</DisableAppDomain> </RunConfiguration> </RunSettings>"; RunSettingsHelper.ReadRunSettings(settingsXml); // Use element value, not attribute value Assert.True(RunSettingsHelper.DisableAppDomain); // Ignore value that isn't at the right level Assert.False(RunSettingsHelper.DisableParallelization); }
public void RunSettingsHelperShouldUseDefaultValuesInCaseOfIncorrectSchemaAndIgnoreAttributes() { string settingsXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> <OuterElement> <DisableParallelization>true</DisableParallelization> </OuterElement> <DisableAppDomain value=""false"">true</DisableAppDomain> </RunConfiguration> </RunSettings>"; RunSettingsHelper.ReadRunSettings(settingsXml); // Attribute must be ignored Assert.True(RunSettingsHelper.DisableAppDomain); // Default value must be used for disableparallelization Assert.False(RunSettingsHelper.DisableParallelization); }
public void RunSettingsHelperShouldReadDesignModeSettingCorrectly(bool designMode) { string settingsXml = $@"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> <DisableAppDomain>true</DisableAppDomain> <DisableParallelization>invalid</DisableParallelization> <DesignMode>{designMode.ToString().ToLowerInvariant()}</DesignMode> </RunConfiguration> </RunSettings>"; RunSettingsHelper.ReadRunSettings(settingsXml); // Correct values must be set Assert.Equal(designMode, RunSettingsHelper.DesignMode); Assert.True(RunSettingsHelper.DisableAppDomain); // Default value should be set for DisableParallelization Assert.False(RunSettingsHelper.DisableParallelization); }
public void RunSettingsHelperShouldIgnoreEvenIfAdditionalElementsExist() { string settingsXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> <TargetPlatform>x64</TargetPlatform> <TargetFrameworkVersion>FrameworkCore10</TargetFrameworkVersion> <SolutionDirectory>%temp%</SolutionDirectory> <DisableAppDomain>true</DisableAppDomain> <DisableParallelization>true</DisableParallelization> <MaxCpuCount>4</MaxCpuCount> </RunConfiguration> </RunSettings>"; RunSettingsHelper.ReadRunSettings(settingsXml); // Correct values must be used Assert.True(RunSettingsHelper.DisableAppDomain); Assert.True(RunSettingsHelper.DisableParallelization); }
public void RunSettingsHelperShouldReadValuesCorrectly(bool testValue) { string settingsXml = $@"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> <CollectSourceInformation>{testValue.ToString().ToLowerInvariant()}</CollectSourceInformation> <DesignMode>{testValue.ToString().ToLowerInvariant()}</DesignMode> <DisableAppDomain>{testValue.ToString().ToLowerInvariant()}</DisableAppDomain> <DisableParallelization>{testValue.ToString().ToLowerInvariant()}</DisableParallelization> <NoAutoReporters>{testValue.ToString().ToLowerInvariant()}</NoAutoReporters> </RunConfiguration> </RunSettings>"; RunSettingsHelper.ReadRunSettings(settingsXml); Assert.Equal(testValue, RunSettingsHelper.CollectSourceInformation); Assert.Equal(testValue, RunSettingsHelper.DesignMode); Assert.Equal(testValue, RunSettingsHelper.DisableAppDomain); Assert.Equal(testValue, RunSettingsHelper.DisableParallelization); Assert.Equal(testValue, RunSettingsHelper.NoAutoReporters); }