public virtual void UsingKeyTest() { const int key = 42; var s = Create(); var x = s.As <ITestConfiguration>().As <int>(); x.Reset(key); AssertCfg.IsDefault(x.Readonly(key)); var c = x.Realtime(key); c.String = MagicLine; s.Flush(); var s2 = Create(); var y = s2.As <int, ITestConfiguration>(); Assert.IsTrue(y.IsExist(key)); AssertCfg.IsNotDefault(y.Readonly(key)); Assert.AreEqual(c.String, y.Readonly(key).String); y.Reset(key); var s3 = Create(); var z = s3.As <int, ITestConfiguration>(); Assert.IsFalse(z.IsExist(key)); }
public virtual void MultipleInstancesLoadTest() { var saver = Create(); var x = saver.As <ITestConfiguration>(); Console.WriteLine("Clear settings."); x.Reset(); var cfg = x.Realtime(); // should be in the default state AssertCfg.IsDefault(cfg); Console.WriteLine("Changing settings"); cfg.Int32 = MagicNumber; cfg.String = MagicLine; Console.WriteLine("Waiting file write"); saver.Flush(); // should not be in the default state AssertCfg.IsNotDefault(x.Readonly()); Console.WriteLine("Read and compare"); // should be equal AssertCfg.AssertEqualProperties(x.Readonly(), Create().Readonly <ITestConfiguration>()); }
protected virtual void LoadTest(T ctr) { var cfg = ctr.Copy<ITestConfiguration>(); cfg.Int32 = MagicNumber; cfg.String = MagicLine; ctr.Save(cfg); // should not be in the default state AssertCfg.IsNotDefault(ctr.Readonly<ITestConfiguration>()); // should be equal AssertCfg.AssertEqualProperties(cfg, ctr.Readonly<ITestConfiguration>()); }
protected virtual void ComplexLoadTest(T ctr) { var cfg = ctr.Copy<IComplexConfig>(); cfg.ValueArray = ComplexConfig.MagicArray; cfg.ValueList = new List<int>(ComplexConfig.MagicArray); cfg.ValueDictionary = new Dictionary<int, string>(ComplexConfig.MagicDictionary); ctr.Save(cfg); // should not be in the default state AssertCfg.IsNotDefault(ctr.Readonly<IComplexConfig>()); // should be equal AssertCfg.AssertEqualProperties(cfg, ctr.Readonly<IComplexConfig>()); }
protected virtual void ResetTest(T ctr) { var x = ctr.As<ITestConfiguration>(); // changing configuration var cfg = x.Realtime(); cfg.Int32 = MagicNumber; cfg.String = MagicLine; // should not be in the default state AssertCfg.IsNotDefault(x.Readonly()); // reseting configuration x.Reset(); // checking that it in default state now AssertCfg.IsDefault(x.Readonly()); }
protected virtual void ComplexResetTest(T ctr) { // changing configuration var cfg = ctr.Copy<IComplexConfig>(); cfg.ValueArray = ComplexConfig.MagicArray; cfg.ValueList = new List<int>(ComplexConfig.MagicArray); cfg.ValueDictionary = new Dictionary<int, string>(ComplexConfig.MagicDictionary); ctr.Save(cfg); // should not be in the default state AssertCfg.IsNotDefault(ctr.Readonly<IComplexConfig>()); // reseting configuration ctr.Reset<ITestConfiguration>(); // checking that it in default state now AssertCfg.IsDefault(ctr.Readonly<IComplexConfig>()); }
public void RealtimeMemoryConfigurationEditTest() { var ctr = new MemoryConfigurator(); ctr.Reset <ITestConfiguration>(); var cfg = ctr.Realtime <ITestConfiguration>(); AssertCfg.IsDefault(cfg); const string message = "Testing realtime"; cfg.String = message; var other = ctr.Readonly <ITestConfiguration>(); AssertCfg.IsNotDefault(cfg); AssertCfg.IsNotDefault(other); Assert.AreEqual(cfg.String, message, "realtime config not changed"); Assert.AreEqual(other.String, message, "readonly config not actual"); }