Exemple #1
0
        public void Struct()
        {
            var empty       = new EmptyTestStruct();
            var emptyActual = empty.Dump();

            Assert.AreEqual("{}", emptyActual);

            var obj1 = new TestStructWithField {
                Key1 = "Value1", Key2 = "Value2", Key3 = "Value3"
            };
            var actual1 = obj1.Dump();

            Assert.AreEqual("{Key1=Value1,Key2=Value2,Key3=Value3}", actual1);

            var obj2    = new TestStructWithField();
            var actual2 = obj2.Dump();

            Assert.AreEqual("{Key1=,Key2=,Key3=}", actual2);

            var obj3 = new TestStructWithProperty {
                Property1 = "Value1", Property2 = "Value2"
            };
            var actual3 = obj3.Dump();

            Assert.AreEqual("{Property1=Value1,Property2=Value2}", actual3);

            var obj4 = new TestStructWithFieldProperty {
                Key1 = "Value1", Property2 = "Value2"
            };
            var actual4 = obj4.Dump();

            Assert.AreEqual("{Key1=Value1,Property2=Value2}", actual4);
        }
        public void Struct()
        {
            var empty         = new EmptyTestStruct();
            var emptyActual   = empty.Apply((ref EmptyTestStruct self) => { });
            var emptyExpected = new EmptyTestStruct();

            Assert.AreEqual(emptyExpected, emptyActual);

            var actual = new TestStructWithField().Apply((ref TestStructWithField self) =>
            {
                self.Key1 = "Value1";
                self.Key2 = "Value2";
                self.Key3 = "Value3";
            });
            var expected = new TestStructWithField {
                Key1 = "Value1", Key2 = "Value2", Key3 = "Value3"
            };

            Assert.AreEqual(expected.Key1, actual.Key1);
            Assert.AreEqual(expected.Key2, actual.Key2);
            Assert.AreEqual(expected.Key3, actual.Key3);
        }