Exemplo n.º 1
0
        public void SaveConfigurationTest()
        {
            //Arrange
            string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.json");

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            //Act
            _compare.SaveConfiguration(filePath);

            //Assert
            Assert.IsTrue(File.Exists(filePath));
        }
Exemplo n.º 2
0
        public void SerializationException()
        {
            //This is the comparison class
            CompareLogic compareLogic = new CompareLogic();
            string       filePath     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SerializationException.json");

            compareLogic.Config.TypesToIgnore.Add(typeof(Guid));
            compareLogic.SaveConfiguration(filePath);
            compareLogic.LoadConfiguration(filePath);


            //Create a couple objects to compare
            Person person1 = new Person();

            person1.DateCreated = DateTime.Now;
            person1.Name        = "Greg";

            Person person2 = new Person();

            person2.Name        = "John";
            person2.DateCreated = person1.DateCreated;

            ComparisonResult result = compareLogic.Compare(person1, person2);

            //These will be different, write out the differences
            if (!result.AreEqual)
            {
                Console.WriteLine(result.DifferencesString);
            }
            else
            {
                Console.WriteLine("Objects are the same");
            }
        }
Exemplo n.º 3
0
        public void HashsetStringsShouldSerializeAndDeserialize()
        {
            //This is the comparison class
            CompareLogic compareLogic = new CompareLogic();
            string       filePath     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "HashsetStringTest.json");

            compareLogic.Config.MembersToIgnore.Add("CreateDate");
            compareLogic.Config.MembersToInclude.Add("OrderId");
            compareLogic.SaveConfiguration(filePath);
            compareLogic.LoadConfiguration(filePath);

            Assert.IsTrue(compareLogic.Config.MembersToIgnore.Contains(("CreateDate")));
            Assert.IsTrue(compareLogic.Config.MembersToInclude.Contains(("OrderId")));
        }