public void GlobalThenCurrent() { AtataContext.GlobalConfiguration. ApplyJsonConfig <CustomJsonConfig>(@"Configs/CustomSettings.json"); AtataContext.Configure(). ApplyJsonConfig <CustomJsonConfig>(@"Configs/CustomSettingsOverride.json"). Build(); CustomJsonConfig.Global.BaseUrl.Should().Be("https://demo.atata.io/"); CustomJsonConfig.Current.BaseUrl.Should().Be("https://demo.atata.io/override"); CustomJsonConfig.Global.StringProperty.Should().Be("str"); CustomJsonConfig.Current.StringProperty.Should().Be("str2"); CustomJsonConfig.Global.StringListValues.Should().Equal(new[] { "str1", "str2", "str3" }); CustomJsonConfig.Current.StringListValues.Should().Equal(new[] { "str1", "str2", "str3", "str4" }); AtataContext parallelAtataContext = null; CustomJsonConfig parallelCustomJsonConfig = null; Task.Run(() => { parallelAtataContext = AtataContext.Configure(). ApplyJsonConfig <CustomJsonConfig>(@"Configs/CustomSettingsOverride2.json"). Build(); parallelCustomJsonConfig = CustomJsonConfig.Current; }).Wait(); try { CustomJsonConfig.Global.BaseUrl.Should().Be("https://demo.atata.io/"); CustomJsonConfig.Current.BaseUrl.Should().Be("https://demo.atata.io/override"); CustomJsonConfig.Current.StringProperty.Should().Be("str2"); CustomJsonConfig.Current.StringListValues.Should().Equal(new[] { "str1", "str2", "str3", "str4" }); parallelCustomJsonConfig.BaseUrl.Should().Be("https://demo.atata.io/override2"); parallelCustomJsonConfig.StringProperty.Should().Be("str3"); parallelCustomJsonConfig.StringListValues.Should().Equal(new[] { "str1", "str2", "str3", "str5" }); AtataContext.Current.CleanUp(); CustomJsonConfig.Current.Should().BeNull(); CustomJsonConfig.Global.BaseUrl.Should().Be("https://demo.atata.io/"); CustomJsonConfig.Global.StringProperty.Should().Be("str"); CustomJsonConfig.Global.StringListValues.Should().Equal(new[] { "str1", "str2", "str3" }); } finally { parallelAtataContext.CleanUp(); } }
public void Custom() { string jsonContent = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Configs/CustomSettings.json")); CustomJsonConfig config = JsonConvert.DeserializeObject <CustomJsonConfig>(jsonContent); AtataContextBuilder builder = AtataContext.Configure(). ApplyJsonConfig(config); CustomJsonConfig.Current.Should().BeNull(); config.BaseUrl.Should().Be("https://demo.atata.io/"); config.IntProperty.Should().Be(5); config.StringArrayValues.Should().Equal(new[] { "str1", "str2", "str3" }); builder.BuildingContext.DriverFactories.Should().HaveCount(1); builder.BuildingContext.BaseUrl.Should().Be("https://demo.atata.io/"); }