Skip to content
Closed
Show file tree
Hide file tree
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
@@ -1,6 +1,6 @@
namespace TestStack.White.Reporting.Configuration
{
public interface ReportingConfiguration
public interface IReportingConfiguration
{
bool PublishTestReports { get; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace TestStack.White.Reporting.Configuration
{
public class ReportingAppXmlConfiguration : AssemblyConfiguration, ReportingConfiguration
public class ReportingAppXmlConfiguration : AssemblyConfiguration, IReportingConfiguration
{
private static ReportingConfiguration instance;
private static IReportingConfiguration instance;

private static readonly Dictionary<string, object> DefaultValues = new Dictionary<string, object>();

Expand All @@ -19,7 +19,7 @@ static ReportingAppXmlConfiguration()
private ReportingAppXmlConfiguration() : base("White", "Reporting", DefaultValues,
CoreAppXmlConfiguration.Instance.LoggerFactory.Create(typeof(ReportingAppXmlConfiguration))) {}

public static ReportingConfiguration Instance
public static IReportingConfiguration Instance
{
get { return instance ?? (instance = new ReportingAppXmlConfiguration()); }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Configuration\ReportingAppXmlConfiguration.cs" />
<Compile Include="Configuration\ReportingConfiguration.cs" />
<Compile Include="Configuration\IReportingConfiguration.cs" />
<Compile Include="Domain\IReport.cs" />
<Compile Include="Domain\NullSessionReport.cs" />
<Compile Include="Domain\ReportWriter.cs" />
Expand Down Expand Up @@ -113,5 +113,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>

</Project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
using System.Collections.Generic;
using System.IO;
using TestStack.White.Configuration;

namespace TestStack.White.ScreenObjects.Configuration
{
//TODO: Power management
public interface RepositoryConfiguration
public class RepositoryConfiguration : ConfigurationBase
{
bool RecordFlow { get; }
DirectoryInfo ServiceCallHistoryLocation { get; }
bool UseHistory { get; }
private const string RecordFlowKey = "RecordFlow";
private const string ServiceCallHistoryLocationKey = "ServiceCallHistoryLocation";
private const string UseHistoryKey = "UseHistory";

public bool RecordFlow
{
get { return GetValueBoolean(RecordFlowKey); }
set { SetValue(RecordFlowKey, value); }
}

public DirectoryInfo ServiceCallHistoryLocation
{
get { return new DirectoryInfo(GetValue(ServiceCallHistoryLocationKey)); }
set { SetValue(ServiceCallHistoryLocationKey, value); }
}

public bool UseHistory
{
get { return GetValueBoolean(UseHistoryKey); }
set { SetValue(UseHistoryKey, value); }
}

public override Dictionary<string, object> DefaultValues
{
get
{
return new Dictionary<string, object>
{
{RecordFlowKey, false},
{ServiceCallHistoryLocationKey, "."},
{UseHistoryKey, false}
};
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using TestStack.White.Configuration;

namespace TestStack.White.ScreenObjects.Configuration
{
public static class RepositoryConfigurationLocator
{
private static RepositoryConfiguration repositoryConfiguration;

public static RepositoryConfiguration Get()
{
if (repositoryConfiguration == null)
{
Register(new AppConfigReader("White", "Repository"));
}
return repositoryConfiguration;
}

public static void Register(ConfigurationReaderBase configurationReader)
{
repositoryConfiguration = new RepositoryConfiguration();
configurationReader.FillConfigurationFromReader(repositoryConfiguration);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public virtual void RevertToSnapshot()

public static ServiceExecution Create(IWorkEnvironment workEnvironment)
{
if (!RepositoryAppXmlConfiguration.Instance.UseHistory)
if (!RepositoryConfigurationLocator.Get().UseHistory)
return new NullServiceExecution();
ExecutionHistory executionHistory = ExecutionHistory.Create();
return new ServiceExecution(executionHistory, workEnvironment ?? new NullWorkEnvironment());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public virtual T GetService<T>(params object[] objs) where T : Service
if (services.TryGetValue(typeof (T), out service)) return (T) service;

service = (T) Activator.CreateInstance(typeof(T), objs);
if (RepositoryAppXmlConfiguration.Instance.UseHistory || ReportingAppXmlConfiguration.Instance.PublishTestReports)
if (RepositoryConfigurationLocator.Get().UseHistory || ReportingAppXmlConfiguration.Instance.PublishTestReports)
{
service = (Service) DynamicProxyGenerator.Instance.CreateProxy(typeof (T), new ServiceInterceptor(service, serviceExecution, sessionReport));
services.Add(typeof (T), service);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
<Compile Include="AppScreenComponent.cs" />
<Compile Include="AppScreenException.cs" />
<Compile Include="AppWindow.cs" />
<Compile Include="Configuration\RepositoryConfiguration.cs" />
<Compile Include="Configuration\RepositoryConfigurationLocator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScreenAttributes\AutomationIdAttribute.cs" />
<Compile Include="ScreenAttributes\FrameworkIdAttribute.cs" />
<Compile Include="ScreenAttributes\IndexAttribute.cs" />
<Compile Include="Configuration\RepositoryAppXmlConfiguration.cs" />
<Compile Include="Configuration\RepositoryConfiguration.cs" />
<Compile Include="EntityMapping\Entities.cs" />
<Compile Include="EntityMapping\Entity.cs" />
<Compile Include="EntityMapping\EntityField.cs" />
Expand Down Expand Up @@ -161,5 +161,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>

</Project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace TestStack.White.WebBrowser.Configuration
{
public interface IWebBrowserConfiguration
{
int FirefoxSingleWindowCheckWait { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,20 @@
using TestStack.White.Bricks;
using TestStack.White.Configuration;

namespace TestStack.White.WebBrowser.Config
namespace TestStack.White.WebBrowser.Configuration
{
public class WebBrowserAppXmlConfiguration : AssemblyConfiguration, WebBrowserConfiguration
public class WebBrowserAppXmlConfiguration : AssemblyConfiguration, IWebBrowserConfiguration
{
private static readonly Dictionary<string, object> DefaultValues = new Dictionary<string, object>();
private static WebBrowserConfiguration instance;

static WebBrowserAppXmlConfiguration()
{
DefaultValues.Add("FirefoxSingleWindowCheckWait", 2000);
}

private WebBrowserAppXmlConfiguration() : base("White", "WebBrowser", DefaultValues,
CoreAppXmlConfiguration.Instance.LoggerFactory.Create(typeof(WebBrowserAppXmlConfiguration))){}

public static WebBrowserConfiguration Instance
{
get { return instance ?? (instance = new WebBrowserAppXmlConfiguration()); }
}
public WebBrowserAppXmlConfiguration()
: base("White", "WebBrowser", DefaultValues,
CoreAppXmlConfiguration.Instance.LoggerFactory.Create(typeof(WebBrowserAppXmlConfiguration))) { }

public virtual int FirefoxSingleWindowCheckWait
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;

namespace TestStack.White.WebBrowser.Configuration
{
public static class WebBrowserConfigurationLocator
{
private static IWebBrowserConfiguration webBrowserConfiguration;

public static IWebBrowserConfiguration Get()
{
if (webBrowserConfiguration == null)
{
webBrowserConfiguration = new WebBrowserAppXmlConfiguration();
}
return webBrowserConfiguration;
}

public static void Register(IWebBrowserConfiguration webBrowserConfiguration)
{
WebBrowserConfigurationLocator.webBrowserConfiguration = webBrowserConfiguration;
}
}
}
4 changes: 2 additions & 2 deletions src/TestStack.White.WebBrowser/Firefox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Diagnostics;
using System.Threading;
using TestStack.White.UIItems.WindowItems;
using TestStack.White.WebBrowser.Config;
using TestStack.White.WebBrowser.Configuration;

namespace TestStack.White.WebBrowser
{
Expand All @@ -26,7 +26,7 @@ public static FirefoxWindow Launch(string url)
string commandLine = string.Format("-new-window {0}", url);
var processStartInfo = new ProcessStartInfo {FileName = executable, Arguments = commandLine};
Application application = Application.Launch(processStartInfo);
Thread.Sleep(WebBrowserAppXmlConfiguration.Instance.FirefoxSingleWindowCheckWait);
Thread.Sleep(WebBrowserConfigurationLocator.Get().FirefoxSingleWindowCheckWait);
int numberOfFirefoxProcessesAfterLaunch = Process.GetProcessesByName(executableName).Length;
bool processPerWindow = numberOfFirefoxProcessesAfterLaunch > numberBeforeLaunch;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\WebBrowserConfigurationLocator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="FirefoxFactory.cs" />
<Compile Include="BrowserWindow.cs" />
<Compile Include="Config\WebBrowserAppXmlConfiguration.cs" />
<Compile Include="Configuration\WebBrowserAppXmlConfiguration.cs" />
<Compile Include="FirefoxWindow.cs" />
<Compile Include="Firefox.cs" />
<Compile Include="Config\WebBrowserConfiguration.cs" />
<Compile Include="Configuration\IWebBrowserConfiguration.cs" />
<Compile Include="InternetExplorerFactory.cs" />
<Compile Include="InternetExplorerWindow.cs" />
<Compile Include="InternetExplorer.cs" />
Expand Down Expand Up @@ -128,5 +129,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>

</Project>
47 changes: 47 additions & 0 deletions src/TestStack.White/Configuration/AppConfigReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;

namespace TestStack.White.Configuration
{
/// <summary>
/// Configuration reader which reads from the app.config file
/// </summary>
public class AppConfigReader : ConfigurationReaderBase
{
private NameValueCollection nameValues;

public AppConfigReader(string sectionGroup, string sectionName)
{
nameValues = (NameValueCollection)ConfigurationManager.GetSection(sectionGroup + "/" + sectionName);
if (nameValues == null)
{
nameValues = new NameValueCollection();
}
}

protected override void FillConfigurationFromReaderInternal(ConfigurationBase configuration)
{
// Overwrite the values contained in the section
foreach (var key in nameValues.AllKeys)
{
var value = nameValues.Get(key);
if (value != null)
{
configuration.SetValue(key, value);
}
}
// Overwrite the values from the AppSettings
var allKeys = new List<string>(nameValues.AllKeys);
allKeys.AddRange(configuration.DefaultValues.Keys);
foreach (var key in allKeys)
{
var value = ConfigurationManager.AppSettings[key];
if (value != null)
{
configuration.SetValue(key, value);
}
}
}
}
}
Loading