diff --git a/src/Samples/Wpf/WpfTodo.UITests/TodoAppTests.cs b/src/Samples/Wpf/WpfTodo.UITests/TodoAppTests.cs index 6889da44..cdc38f0d 100644 --- a/src/Samples/Wpf/WpfTodo.UITests/TodoAppTests.cs +++ b/src/Samples/Wpf/WpfTodo.UITests/TodoAppTests.cs @@ -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); diff --git a/src/TestStack.White.Reporting/Configuration/ReportingAppXmlConfiguration.cs b/src/TestStack.White.Reporting/Configuration/ReportingAppXmlConfiguration.cs deleted file mode 100644 index 88847497..00000000 --- a/src/TestStack.White.Reporting/Configuration/ReportingAppXmlConfiguration.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using TestStack.White.Bricks; -using TestStack.White.Configuration; - -namespace TestStack.White.Reporting.Configuration -{ - public class ReportingAppXmlConfiguration : AssemblyConfiguration, ReportingConfiguration - { - private static ReportingConfiguration instance; - - private static readonly Dictionary DefaultValues = new Dictionary(); - - static ReportingAppXmlConfiguration() - { - DefaultValues.Add("PublishTestReports", true); - } - - private ReportingAppXmlConfiguration() : base("White", "Reporting", DefaultValues, - CoreAppXmlConfiguration.Instance.LoggerFactory.Create(typeof(ReportingAppXmlConfiguration))) {} - - public static ReportingConfiguration Instance - { - get { return instance ?? (instance = new ReportingAppXmlConfiguration()); } - } - - public virtual bool PublishTestReports - { - get { return Convert.ToBoolean(UsedValues["PublishTestReports"]); } - } - } -} \ No newline at end of file diff --git a/src/TestStack.White.Reporting/Configuration/ReportingConfiguration.cs b/src/TestStack.White.Reporting/Configuration/ReportingConfiguration.cs index 74a0cc36..b434fbd0 100644 --- a/src/TestStack.White.Reporting/Configuration/ReportingConfiguration.cs +++ b/src/TestStack.White.Reporting/Configuration/ReportingConfiguration.cs @@ -1,7 +1,27 @@ +using System.Collections.Generic; +using TestStack.White.Configuration; + namespace TestStack.White.Reporting.Configuration { - public interface ReportingConfiguration + public class ReportingConfiguration : ConfigurationBase { - bool PublishTestReports { get; } + private const string PublishTestReportsKey = "PublishTestReports"; + + public override Dictionary DefaultValues + { + get + { + return new Dictionary + { + {PublishTestReportsKey, true} + }; + } + } + + public virtual bool PublishTestReports + { + get { return GetValueBoolean(PublishTestReportsKey); } + set { SetValue(PublishTestReportsKey, value); } + } } } \ No newline at end of file diff --git a/src/TestStack.White.Reporting/Configuration/ReportingConfigurationLocator.cs b/src/TestStack.White.Reporting/Configuration/ReportingConfigurationLocator.cs new file mode 100644 index 00000000..df99e74c --- /dev/null +++ b/src/TestStack.White.Reporting/Configuration/ReportingConfigurationLocator.cs @@ -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); + } + } +} diff --git a/src/TestStack.White.Reporting/Domain/SubFlow.cs b/src/TestStack.White.Reporting/Domain/SubFlow.cs index d99a0a4d..f30b12c1 100644 --- a/src/TestStack.White.Reporting/Domain/SubFlow.cs +++ b/src/TestStack.White.Reporting/Domain/SubFlow.cs @@ -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) { diff --git a/src/TestStack.White.Reporting/Domain/SubFlows.cs b/src/TestStack.White.Reporting/Domain/SubFlows.cs index 1e52240f..f38d49cc 100644 --- a/src/TestStack.White.Reporting/Domain/SubFlows.cs +++ b/src/TestStack.White.Reporting/Domain/SubFlows.cs @@ -11,7 +11,7 @@ public class SubFlows : List 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) { diff --git a/src/TestStack.White.Reporting/TestStack.White.Reporting.csproj b/src/TestStack.White.Reporting/TestStack.White.Reporting.csproj index ede5ba94..55b252ef 100644 --- a/src/TestStack.White.Reporting/TestStack.White.Reporting.csproj +++ b/src/TestStack.White.Reporting/TestStack.White.Reporting.csproj @@ -71,8 +71,8 @@ + - @@ -113,5 +113,4 @@ --> - - + \ No newline at end of file diff --git a/src/TestStack.White.ScreenObjects/AppScreen.cs b/src/TestStack.White.ScreenObjects/AppScreen.cs index 84eee408..6460a7e2 100644 --- a/src/TestStack.White.ScreenObjects/AppScreen.cs +++ b/src/TestStack.White.ScreenObjects/AppScreen.cs @@ -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) {} diff --git a/src/TestStack.White.ScreenObjects/Configuration/RepositoryAppXmlConfiguration.cs b/src/TestStack.White.ScreenObjects/Configuration/RepositoryAppXmlConfiguration.cs deleted file mode 100644 index 14e66f1a..00000000 --- a/src/TestStack.White.ScreenObjects/Configuration/RepositoryAppXmlConfiguration.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using TestStack.White.Bricks; -using TestStack.White.Configuration; - -namespace TestStack.White.ScreenObjects.Configuration -{ - public class RepositoryAppXmlConfiguration : AssemblyConfiguration, RepositoryConfiguration - { - public static RepositoryConfiguration instance; - - private static readonly Dictionary DefaultValues = new Dictionary(); - private const string UseHistoryKey = "UseHistory"; - private const string ServiceCallHistoryLocationKey = "ServiceCallHistoryLocation"; - private const string RecordFlowKey = "RecordFlow"; - - static RepositoryAppXmlConfiguration() - { - DefaultValues[RecordFlowKey] = false; - DefaultValues[ServiceCallHistoryLocationKey] = "."; - DefaultValues[UseHistoryKey] = false; - } - - public static RepositoryConfiguration Instance - { - get { return instance ?? (instance = new RepositoryAppXmlConfiguration()); } - } - - private RepositoryAppXmlConfiguration() : base("White", "Repository", DefaultValues, - CoreAppXmlConfiguration.Instance.LoggerFactory.Create(typeof(RepositoryAppXmlConfiguration))) {} - - public virtual bool RecordFlow - { - get { return Convert.ToBoolean(UsedValues[RecordFlowKey]); } - } - - public virtual DirectoryInfo ServiceCallHistoryLocation - { - get { return new DirectoryInfo(UsedValues[ServiceCallHistoryLocationKey]); } - } - - public virtual bool UseHistory - { - get { return Convert.ToBoolean(UsedValues[UseHistoryKey]); } - } - } -} \ No newline at end of file diff --git a/src/TestStack.White.ScreenObjects/Configuration/RepositoryConfiguration.cs b/src/TestStack.White.ScreenObjects/Configuration/RepositoryConfiguration.cs index 28e6f549..98f76621 100644 --- a/src/TestStack.White.ScreenObjects/Configuration/RepositoryConfiguration.cs +++ b/src/TestStack.White.ScreenObjects/Configuration/RepositoryConfiguration.cs @@ -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 { - 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 DefaultValues + { + get + { + return new Dictionary + { + {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); } + } } } \ No newline at end of file diff --git a/src/TestStack.White.ScreenObjects/Configuration/RepositoryConfigurationLocator.cs b/src/TestStack.White.ScreenObjects/Configuration/RepositoryConfigurationLocator.cs new file mode 100644 index 00000000..79632c73 --- /dev/null +++ b/src/TestStack.White.ScreenObjects/Configuration/RepositoryConfigurationLocator.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/src/TestStack.White.ScreenObjects/EntityMapping/Entity.cs b/src/TestStack.White.ScreenObjects/EntityMapping/Entity.cs index f5eb8fd6..6a9ce153 100644 --- a/src/TestStack.White.ScreenObjects/EntityMapping/Entity.cs +++ b/src/TestStack.White.ScreenObjects/EntityMapping/Entity.cs @@ -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() {} diff --git a/src/TestStack.White.ScreenObjects/ScreenFlow/WorkFlow.cs b/src/TestStack.White.ScreenObjects/ScreenFlow/WorkFlow.cs index f93d4240..a4d075e8 100644 --- a/src/TestStack.White.ScreenObjects/ScreenFlow/WorkFlow.cs +++ b/src/TestStack.White.ScreenObjects/ScreenFlow/WorkFlow.cs @@ -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) { diff --git a/src/TestStack.White.ScreenObjects/Services/ExecutionHistory.cs b/src/TestStack.White.ScreenObjects/Services/ExecutionHistory.cs index eeb84851..4fee6792 100644 --- a/src/TestStack.White.ScreenObjects/Services/ExecutionHistory.cs +++ b/src/TestStack.White.ScreenObjects/Services/ExecutionHistory.cs @@ -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() { diff --git a/src/TestStack.White.ScreenObjects/Services/ServiceExecution.cs b/src/TestStack.White.ScreenObjects/Services/ServiceExecution.cs index 17a59b0e..871acfbe 100644 --- a/src/TestStack.White.ScreenObjects/Services/ServiceExecution.cs +++ b/src/TestStack.White.ScreenObjects/Services/ServiceExecution.cs @@ -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()); diff --git a/src/TestStack.White.ScreenObjects/Services/WhiteExecution.cs b/src/TestStack.White.ScreenObjects/Services/WhiteExecution.cs index 88f0db16..0819a5b8 100644 --- a/src/TestStack.White.ScreenObjects/Services/WhiteExecution.cs +++ b/src/TestStack.White.ScreenObjects/Services/WhiteExecution.cs @@ -37,7 +37,7 @@ public virtual T GetService(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); diff --git a/src/TestStack.White.ScreenObjects/Sessions/WorkConfiguration.cs b/src/TestStack.White.ScreenObjects/Sessions/WorkConfiguration.cs index 591a899f..a05d770f 100644 --- a/src/TestStack.White.ScreenObjects/Sessions/WorkConfiguration.cs +++ b/src/TestStack.White.ScreenObjects/Sessions/WorkConfiguration.cs @@ -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(); } diff --git a/src/TestStack.White.ScreenObjects/TestStack.White.ScreenObjects.csproj b/src/TestStack.White.ScreenObjects/TestStack.White.ScreenObjects.csproj index f86f229f..2b40f14c 100644 --- a/src/TestStack.White.ScreenObjects/TestStack.White.ScreenObjects.csproj +++ b/src/TestStack.White.ScreenObjects/TestStack.White.ScreenObjects.csproj @@ -83,11 +83,11 @@ + - diff --git a/src/TestStack.White.UITests/AutomationElementSearch/RawAutomationElementFinderTests.cs b/src/TestStack.White.UITests/AutomationElementSearch/RawAutomationElementFinderTests.cs index 8ec3d2ac..3ea840b3 100644 --- a/src/TestStack.White.UITests/AutomationElementSearch/RawAutomationElementFinderTests.cs +++ b/src/TestStack.White.UITests/AutomationElementSearch/RawAutomationElementFinderTests.cs @@ -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; diff --git a/src/TestStack.White.UITests/ControlTests/ButtonTests.cs b/src/TestStack.White.UITests/ControlTests/ButtonTests.cs index 5652325b..48a11f03 100644 --- a/src/TestStack.White.UITests/ControlTests/ButtonTests.cs +++ b/src/TestStack.White.UITests/ControlTests/ButtonTests.cs @@ -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