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

Configuration cleanup #380

Open
wants to merge 3 commits into
base: UIAComWrapper
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/Samples/Wpf/WpfTodo.UITests/TodoAppTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void AutomateTest()
Name = "WpfTodo"
};

CoreAppXmlConfiguration.Instance.WorkSessionLocation = new DirectoryInfo(workPath);
CoreConfigurationLocator.Get().WorkSessionLocation = new DirectoryInfo(workPath);
using (var workSession = new WorkSession(workConfiguration, new NullWorkEnvironment()))
{
var screenRepository = workSession.Attach(Application);
Expand Down

This file was deleted.

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

namespace TestStack.White.Reporting.Configuration
{
public interface ReportingConfiguration
public class ReportingConfiguration : ConfigurationBase<ReportingConfiguration>
{
bool PublishTestReports { get; }
private const string PublishTestReportsKey = "PublishTestReports";

public override Dictionary<string, object> DefaultValues
{
get
{
return new Dictionary<string, object>
{
{PublishTestReportsKey, true}
};
}
}

public virtual bool PublishTestReports
{
get { return GetValueBoolean(PublishTestReportsKey); }
set { SetValue(PublishTestReportsKey, value); }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using TestStack.White.Configuration.Readers;

namespace TestStack.White.Reporting.Configuration
{
public static class ReportingConfigurationLocator
{
private static ReportingConfiguration reportingConfiguration;

public static ReportingConfiguration Get()
{
if (reportingConfiguration == null)
{
Set(new AppConfigReader("White", "Reporting"));
}
return reportingConfiguration;
}

public static void Set(IConfigurationReader configurationReader)
{
reportingConfiguration = new ReportingConfiguration();
configurationReader.FillConfigurationFromReader(reportingConfiguration);
}
}
}
2 changes: 1 addition & 1 deletion src/TestStack.White.Reporting/Domain/SubFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class SubFlow
private readonly string directory;
private DateTime screenCreationTime;
private readonly string name;
private static readonly ILogger Logger = CoreAppXmlConfiguration.Instance.LoggerFactory.Create(typeof(SubFlow));
private static readonly ILogger Logger = CoreConfigurationLocator.Get().LoggerFactory.Create(typeof(SubFlow));

public SubFlow(string subFlowName, string flowName, string archiveLocation)
{
Expand Down
2 changes: 1 addition & 1 deletion src/TestStack.White.Reporting/Domain/SubFlows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class SubFlows : List<SubFlow>
private readonly string archiveLocation;
private readonly string flowName;
private int currentSubFlowIndex = -1;
private readonly ILogger logger = CoreAppXmlConfiguration.Instance.LoggerFactory.Create(typeof(SubFlow));
private readonly ILogger logger = CoreConfigurationLocator.Get().LoggerFactory.Create(typeof(SubFlow));

public SubFlows(string archiveLocation, string flowName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\ReportingConfigurationLocator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Configuration\ReportingAppXmlConfiguration.cs" />
<Compile Include="Configuration\ReportingConfiguration.cs" />
<Compile Include="Domain\IReport.cs" />
<Compile Include="Domain\NullSessionReport.cs" />
Expand Down Expand Up @@ -113,5 +113,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>

</Project>
2 changes: 1 addition & 1 deletion src/TestStack.White.ScreenObjects/AppScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace TestStack.White.ScreenObjects
//TODO: Take care of act kind of stuff by putting attribute
public class AppScreen : RepositoryComponent
{
private readonly ILogger logger = CoreAppXmlConfiguration.Instance.LoggerFactory.Create(typeof(AppScreen));
private readonly ILogger logger = CoreConfigurationLocator.Get().LoggerFactory.Create(typeof(AppScreen));

public AppScreen(Window window, ScreenRepository screenRepository) : base(window, screenRepository) {}

Expand Down

This file was deleted.

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

namespace TestStack.White.ScreenObjects.Configuration
{
//TODO: Power management
public interface RepositoryConfiguration
// TODO: Power management
public class RepositoryConfiguration : ConfigurationBase<RepositoryConfiguration>
{
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 override Dictionary<string, object> DefaultValues
{
get
{
return new Dictionary<string, object>
{
{RecordFlowKey, false},
{ServiceCallHistoryLocationKey, "."},
{UseHistoryKey, false}
};
}
}

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

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

public virtual bool UseHistory
{
get { return GetValueBoolean(UseHistoryKey); }
set { SetValue(UseHistoryKey, value); }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using TestStack.White.Configuration.Readers;

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

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

public static void Set(IConfigurationReader configurationReader)
{
repositoryConfiguration = new RepositoryConfiguration();
configurationReader.FillConfigurationFromReader(repositoryConfiguration);
}
}
}
2 changes: 1 addition & 1 deletion src/TestStack.White.ScreenObjects/EntityMapping/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace TestStack.White.ScreenObjects.EntityMapping
public class Entity
{
[ScreenIgnore, XmlIgnore] private NestedEntities nestedEntities;
private readonly ILogger logger = CoreAppXmlConfiguration.Instance.LoggerFactory.Create(typeof(Entity));
private readonly ILogger logger = CoreConfigurationLocator.Get().LoggerFactory.Create(typeof(Entity));
internal const BindingFlags BindingFlag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly | BindingFlags.IgnoreCase;

protected Entity() {}
Expand Down
2 changes: 1 addition & 1 deletion src/TestStack.White.ScreenObjects/ScreenFlow/WorkFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class WorkFlow
private readonly GraphWriter graph;
private readonly FlowWriter flow;
private readonly string directory;
private static readonly ILogger Logger = CoreAppXmlConfiguration.Instance.LoggerFactory.Create(typeof(WorkFlow));
private static readonly ILogger Logger = CoreConfigurationLocator.Get().LoggerFactory.Create(typeof(WorkFlow));

public WorkFlow(string name, string archiveLocation)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ExecutionHistory
private bool hasError;

private static readonly string ExecutionHistoryFile =
string.Format(@"{0}\{1}.xml", CoreAppXmlConfiguration.Instance.WorkSessionLocation, "ExecutionHistory");
string.Format(@"{0}\{1}.xml", CoreConfigurationLocator.Get().WorkSessionLocation, "ExecutionHistory");

public ExecutionHistory()
{
Expand Down
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 || ReportingConfigurationLocator.Get().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 @@ -22,7 +22,7 @@ public virtual string Name

public virtual IReport CreateSessionReport()
{
if (ReportingAppXmlConfiguration.Instance.PublishTestReports)
if (ReportingConfigurationLocator.Get().PublishTestReports)
return new SessionReport(archiveLocation, name);
return new NullSessionReport();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@
<Compile Include="AppScreenComponent.cs" />
<Compile Include="AppScreenException.cs" />
<Compile Include="AppWindow.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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public RawAutomationElementFinderTests(WindowsFramework framework)
[OneTimeSetUp]
public void Setup()
{
cleanup = CoreAppXmlConfiguration.Instance.ApplyTemporarySetting(c =>
cleanup = CoreConfigurationLocator.Get().ApplyTemporarySettings(c =>
{
c.RawElementBasedSearch = true;
c.MaxElementSearchDepth = 2;
Expand Down
2 changes: 1 addition & 1 deletion src/TestStack.White.UITests/ControlTests/ButtonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void Click()
[Test]
public void ThrowsWhenNotFound()
{
using (CoreAppXmlConfiguration.Instance.ApplyTemporarySetting(c => c.FindWindowTimeout = 500))
using (CoreConfigurationLocator.Get().ApplyTemporarySettings(c => c.FindWindowTimeout = 500))
{
Assert.That(() => { MainWindow.Get<Button>(SearchCriteria.ByAutomationId("foo")); },
Throws.TypeOf<AutomationException>().With.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void ListItemInComboBoxWithoutTextAvailableInitiallyTest()
Restart();
ComboBoxUnderTest = MainWindow.Get<ComboBox>(SearchCriteria.ByAutomationId("AComboBox"));

var config = CoreAppXmlConfiguration.Instance;
var config = CoreConfigurationLocator.Get();
var originalVal = config.ComboBoxItemsPopulatedWithoutDropDownOpen;
try
{
Expand All @@ -53,7 +53,7 @@ public void ListItemInComboBoxWithoutTextAvailableInitiallyTest()
public void ComboBoxOnlyCollapsesWhenExpansionWasForItemRetrievalTest()
{
// Arrange
var config = CoreAppXmlConfiguration.Instance;
var config = CoreConfigurationLocator.Get();
var originalVal = config.ComboBoxItemsPopulatedWithoutDropDownOpen;
config.ComboBoxItemsPopulatedWithoutDropDownOpen = false;

Expand Down Expand Up @@ -82,7 +82,7 @@ public void ComboBoxOnlyCollapsesWhenExpansionWasForItemRetrievalTest()
public void ComboBoxWithAutoExpandCollapsedOnceItemsAreRetrievedTest()
{
// Arrange
var config = CoreAppXmlConfiguration.Instance;
var config = CoreConfigurationLocator.Get();
var originalVal = config.ComboBoxItemsPopulatedWithoutDropDownOpen;
config.ComboBoxItemsPopulatedWithoutDropDownOpen = false;
try
Expand Down
Loading