コード例 #1
0
        public void AddSimpleTypeSaveAndLoad()
        {
            // Setup
            var file = GetXmlFile(nameof(AddSimpleTypeSaveAndLoad));

            File.Delete(file);
            var set = new XmlSet <SimpleType>(file);

            // Execute
            var simple = new SimpleType
            {
                Name  = "Test",
                Value = 12.35,
                Price = 4.50m,
                Date  = DateTime.Parse("9/1/2015")
            };

            set.Add(simple);
            set.Save();

            var set2   = new XmlSet <SimpleType>(file);
            var result = set2.First();

            // Assert
            Assert.AreEqual(simple.Name, result.Name);
            Assert.AreEqual(simple.Value, result.Value);
            Assert.AreEqual(simple.Price, result.Price);
            Assert.AreEqual(simple.Date, result.Date);
        }
コード例 #2
0
        public void RevertSet()
        {
            // Setup up.
            var file = GetXmlFile(nameof(RevertSet));

            File.Delete(file);
            var set = new XmlSet <SimpleType>(file);

            var simple = new SimpleType
            {
                Name  = "Test",
                Value = 12.35,
                Price = 4.50m,
                Date  = DateTime.Parse("9/1/2015")
            };

            set.Add(simple);
            set.Save();

            var simple2 = new SimpleType
            {
                Name  = "Test 2",
                Value = 43.001,
                Price = 8.5m,
                Date  = DateTime.Parse("9/2/2015")
            };

            // Execute
            set.Revert();

            // Assert
            Assert.AreEqual(1, set.Count);
            Assert.AreEqual(simple.Name, set.First().Name);
        }
コード例 #3
0
ファイル: XmlSetTest.cs プロジェクト: jsmunroe/Helpers
        public void AddComplexTypeSaveAndLoad()
        {
            // Setup
            var file = GetXmlFile(nameof(AddComplexTypeSaveAndLoad));
            File.Delete(file);
            var set = new XmlSet<ComplexType>(file);

            // Execute
            var complex = new ComplexType
            {
                Description = "This is a test",
                Size = 42,
                Child = new SimpleType
                {
                    Name = "Test",
                    Value = 12.35,
                    Price = 4.50m,
                    Date = DateTime.Parse("9/1/2015")
                }
            };
            set.Add(complex);
            set.Save();

            var set2 = new XmlSet<ComplexType>(file);
            var result = set2.First();

            // Assert
            Assert.AreEqual(complex.Description, result.Description);
            Assert.AreEqual(complex.Size, result.Size);
            Assert.IsNotNull(complex.Child);
            Assert.AreEqual(complex.Child.Name, result.Child.Name);
            Assert.AreEqual(complex.Child.Value, result.Child.Value);
            Assert.AreEqual(complex.Child.Price, result.Child.Price);
            Assert.AreEqual(complex.Child.Date, result.Child.Date);
        }
コード例 #4
0
        public void AddComplexTypeSaveAndLoad()
        {
            // Setup
            var file = GetXmlFile(nameof(AddComplexTypeSaveAndLoad));

            File.Delete(file);
            var set = new XmlSet <ComplexType>(file);

            // Execute
            var complex = new ComplexType
            {
                Description = "This is a test",
                Size        = 42,
                Child       = new SimpleType
                {
                    Name  = "Test",
                    Value = 12.35,
                    Price = 4.50m,
                    Date  = DateTime.Parse("9/1/2015")
                }
            };

            set.Add(complex);
            set.Save();

            var set2   = new XmlSet <ComplexType>(file);
            var result = set2.First();

            // Assert
            Assert.AreEqual(complex.Description, result.Description);
            Assert.AreEqual(complex.Size, result.Size);
            Assert.IsNotNull(complex.Child);
            Assert.AreEqual(complex.Child.Name, result.Child.Name);
            Assert.AreEqual(complex.Child.Value, result.Child.Value);
            Assert.AreEqual(complex.Child.Price, result.Child.Price);
            Assert.AreEqual(complex.Child.Date, result.Child.Date);
        }
コード例 #5
0
ファイル: XmlSetTest.cs プロジェクト: jsmunroe/Helpers
        public void AddSimpleTypeSaveAndLoad()
        {
            // Setup
            var file = GetXmlFile(nameof(AddSimpleTypeSaveAndLoad));
            File.Delete(file);
            var set = new XmlSet<SimpleType>(file);

            // Execute
            var simple = new SimpleType
            {
                Name = "Test",
                Value = 12.35,
                Price = 4.50m,
                Date = DateTime.Parse("9/1/2015")
            };
            set.Add(simple);
            set.Save();

            var set2 = new XmlSet<SimpleType>(file);
            var result = set2.First();

            // Assert
            Assert.AreEqual(simple.Name, result.Name);
            Assert.AreEqual(simple.Value, result.Value);
            Assert.AreEqual(simple.Price, result.Price);
            Assert.AreEqual(simple.Date, result.Date);
        }
コード例 #6
0
ファイル: XmlSetTest.cs プロジェクト: jsmunroe/Helpers
        public void RevertSet()
        {
            // Setup up.
            var file = GetXmlFile(nameof(RevertSet));
            File.Delete(file);
            var set = new XmlSet<SimpleType>(file);

            var simple = new SimpleType
            {
                Name = "Test",
                Value = 12.35,
                Price = 4.50m,
                Date = DateTime.Parse("9/1/2015")
            };
            set.Add(simple);
            set.Save();

            var simple2 = new SimpleType
            {
                Name = "Test 2",
                Value = 43.001,
                Price = 8.5m,
                Date = DateTime.Parse("9/2/2015")
            };

            // Execute
            set.Revert();

            // Assert
            Assert.AreEqual(1, set.Count);
            Assert.AreEqual(simple.Name, set.First().Name);
        }