Ejemplo n.º 1
0
        public void Clean_should_clean_complex_classes()
        {
            var guid = Guid.NewGuid();

            var objectToClear1 = new ExampleClass()
            {
                Integer          = 5,
                IntegerCloneable = 5,
                Strign           = "text",
                StrignCloneable  = "text",
                Double           = 1.2,
                DoubleCloneable  = 1.2
            };

            var objectToClear2 = new ExampleClass2()
            {
                Integer          = 5,
                IntegerCloneable = 5
            };

            var objectToClear3 = new ExampleClass3()
            {
                Guid          = guid,
                GuidCloneable = guid
            };

            var objectToClear = new ExampleClass4()
            {
                Guid          = guid,
                GuidCloneable = guid,

                ExampleClass  = objectToClear1,
                ExampleClass2 = objectToClear2,
                ExampleClass3 = objectToClear3
            };

            CloneCleaner.Clean(objectToClear);

            Assert.That(objectToClear.Guid, Is.EqualTo(Guid.Empty));
            Assert.That(objectToClear.GuidCloneable, Is.EqualTo(guid));

            Assert.That(objectToClear.ExampleClass.Integer, Is.EqualTo(0));
            Assert.That(objectToClear.ExampleClass.IntegerCloneable, Is.EqualTo(5));
            Assert.That(objectToClear.ExampleClass.Strign, Is.Null);
            Assert.That(objectToClear.ExampleClass.StrignCloneable, Is.EqualTo("text"));
            Assert.That(objectToClear.ExampleClass.Double, Is.EqualTo(0));
            Assert.That(objectToClear.ExampleClass.DoubleCloneable, Is.EqualTo(1.2));

            Assert.That(objectToClear.ExampleClass2.Integer, Is.Null);
            Assert.That(objectToClear.ExampleClass2.IntegerCloneable, Is.EqualTo(5));

            Assert.That(objectToClear.ExampleClass3.Guid, Is.EqualTo(Guid.Empty));
            Assert.That(objectToClear.ExampleClass3.GuidCloneable, Is.EqualTo(guid));
        }
Ejemplo n.º 2
0
        public void Clean_should_set_empty_guid()
        {
            var guid = Guid.NewGuid();

            var objectToClear = new ExampleClass3()
            {
                Guid          = guid,
                GuidCloneable = guid
            };

            CloneCleaner.Clean(objectToClear);

            Assert.That(objectToClear.Guid, Is.EqualTo(Guid.Empty));
            Assert.That(objectToClear.GuidCloneable, Is.EqualTo(guid));
        }