示例#1
0
        public void PrintToString_ReturnStringWithoutExcludedTypes_WhenManyTypesExcluded()
        {
            var testClass = new TestClassExcluded();
            var person    = new Person {
                Name = "Alex", Age = 19
            };

            testClass.person         = person;
            testClass.TestTextInt    = 2;
            testClass.TestTextString = "text";

            var printer = ObjectPrinter.For <TestClassExcluded>()
                          .Excluding <string>()
                          .Excluding <Person>()
                          .Excluding <double>();

            string s1 = printer.PrintToString(testClass);

            Console.WriteLine("|" + s1 + "|");

            s1.Should().BeEquivalentTo("TestClassExcluded"
                                       + Environment.NewLine
                                       + "\t" + " TestTextInt = 2"
                                       + Environment.NewLine);
        }
示例#2
0
        public void PrintToString_ReturnCorrectString_WhenPropertyExcluded()
        {
            var testClass = new TestClassExcluded();

            testClass.TestTextString = "text!!!";
            var printer = ObjectPrinter.For <TestClassExcluded>()
                          .Excluding(s => s.person)
                          .Excluding(s => s.TestTextDouble)
                          .Excluding(s => s.TestTextInt);

            string s1 = printer.PrintToString(testClass);

            Console.WriteLine("|" + s1 + "|");

            s1.Should().BeEquivalentTo("TestClassExcluded"
                                       + Environment.NewLine
                                       + "\t" + " TestTextString = text!!!"
                                       + Environment.NewLine);
        }
示例#3
0
        public void PrintToString_ReturnCorrectWord_WhenTypeSetCulture()
        {
            var testClass = new TestClassExcluded();

            testClass.TestTextDouble = 2.3;
            var printer = ObjectPrinter.For <TestClassExcluded>()
                          .Excluding <int>()
                          .Excluding <Person>()
                          .Excluding <string>()
                          .Printing <double>().Using(CultureInfo.InvariantCulture);


            string s1 = printer.PrintToString(testClass);

            Console.WriteLine("|" + s1 + "|");

            s1.Should().BeEquivalentTo("TestClassExcluded"
                                       + Environment.NewLine
                                       + "\t" + " TestTextDouble = 2.3"
                                       + Environment.NewLine);
        }
示例#4
0
        public void PrintToString_ReturnCorrectString_WhenUsingAlternativeSerializationForType()
        {
            var testClass = new TestClassExcluded();

            testClass.TestTextInt    = 2;
            testClass.TestTextString = "text";
            var printer = ObjectPrinter.For <TestClassExcluded>()
                          .Excluding <Person>()
                          .Excluding <double>()
                          .Printing <string>().Using(s => s + " + AltSerialize(str)")
                          .Printing <int>().Using(i => i + " + AltSerialize(int)");

            string s1 = printer.PrintToString(testClass);

            Console.WriteLine("|" + s1 + "|");

            s1.Should().BeEquivalentTo("TestClassExcluded"
                                       + Environment.NewLine
                                       + "\t" + " TestTextString = text + AltSerialize(str)"
                                       + Environment.NewLine
                                       + "\t" + " TestTextInt = 2 + AltSerialize(int)"
                                       + Environment.NewLine);
        }