Exemplo n.º 1
0
        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>());
        }
Exemplo n.º 2
0
		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>());
		}
Exemplo n.º 3
0
		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>());
		}
Exemplo n.º 4
0
        public void TestCopyMethod()
        {
            var cfr = ConfigManager.GetDefaultConfigurator();
            var src = cfr.Copy <ITestConfiguration>();
            var dst = new TestConfiguration();

            ChangeConfig(src);
            if (AssertCfg.AreEqualAllProperties(dst, src))
            {
                Assert.Fail();
            }

            dst.Copy(src);
            AssertCfg.AssertEqualProperties(src, dst);
        }