Beispiel #1
0
        public void GetConfText_CanRoundTripComplexListedClassWithBracketedContent1()
        {
            var subject = new ComplexListedClass();

            subject.List.Add(new ComplexClass());
            subject.List[0].Child.StringProp = "hello";
            subject.List[0].DoubleProp       = 1.23;
            subject.List[0].StringProp       = @"world
on more than one

line";
            subject.List.Add(new ComplexClass());
            subject.List[1].Child.StringProp = @"

      
HELLO there

            how's it going?

  
 ";
            subject.List[1].DoubleProp       = 2.34;
            subject.List[1].StringProp       = "WORLD";
            var text = subject.GetConfText();
            var conf = new ConfBlockFactory().CreateConfBlock(text, new TextContentsProvider());
            var copy = conf.Configure(new ComplexListedClass());

            Assert.That(copy.List[0].Child.StringProp, Is.EqualTo(subject.List[0].Child.StringProp));
            Assert.That(copy.List[0].DoubleProp, Is.EqualTo(subject.List[0].DoubleProp));
            Assert.That(copy.List[0].StringProp, Is.EqualTo(subject.List[0].StringProp));
            Assert.That(copy.List[1].Child.StringProp, Is.EqualTo(subject.List[1].Child.StringProp));
            Assert.That(copy.List[1].DoubleProp, Is.EqualTo(subject.List[1].DoubleProp));
            Assert.That(copy.List[1].StringProp, Is.EqualTo(subject.List[1].StringProp));
        }
Beispiel #2
0
        public void GetConfText_CanRoundTripComplexClassMultiline()
        {
            var expected = new ComplexClass();

            expected.StringProp       = string.Join(Environment.NewLine, "mystr", "on", "", "multiple", "lines");
            expected.DoubleProp       = 4.321;
            expected.Child.StringProp = "My other str";

            var text   = expected.GetConfText();
            var conf   = new ConfBlockFactory().CreateConfBlock(text, new TextContentsProvider());
            var actual = conf.Configure(new ComplexClass());

            Assert.That(actual.StringProp, Is.EqualTo(expected.StringProp));
        }
Beispiel #3
0
        public void GetConfText_CanRoundTripDictOfStrings()
        {
            var subject = new DictedClass();

            subject.DictOfStrings[0] = "hello";
            subject.DictOfStrings[1] = "world";
            var text     = subject.GetConfText();
            var conf     = new ConfBlockFactory().CreateConfBlock(text, new TextContentsProvider());
            var copy     = conf.Configure(new DictedClass());
            var actual   = copy.DictOfStrings;
            var expected = subject.DictOfStrings;

            CollectionAssert.AreEqual(expected, actual);
        }
Beispiel #4
0
        private static void GetConfText_CanRoundTripComplexClass(Action <ComplexClass, ComplexClass> assert)
        {
            var expected = new ComplexClass();

            expected.StringProp       = "mystr";
            expected.DoubleProp       = 4.321;
            expected.Child.StringProp = "My other str";

            var text   = expected.GetConfText();
            var conf   = new ConfBlockFactory().CreateConfBlock(text, new TextContentsProvider());
            var actual = conf.Configure(new ComplexClass());

            assert(actual, expected);
        }
Beispiel #5
0
        public void GetConfText_CanRoundTripComplexListedClass(bool multiline)
        {
            var subject = new ComplexListedClass();

            subject.List.Add(new ComplexClass());
            subject.List[0].Child.StringProp = "hello";
            subject.List[0].DoubleProp       = 1.23;
            subject.List[0].StringProp       = "world";
            subject.List.Add(new ComplexClass());
            subject.List[1].Child.StringProp = "HELLO";
            subject.List[1].DoubleProp       = 2.34;
            subject.List[1].StringProp       = "WORLD";
            var text = subject.GetConfText(multiline: multiline);
            var conf = new ConfBlockFactory().CreateConfBlock(text, new TextContentsProvider());
            var copy = conf.Configure(new ComplexListedClass());

            Assert.That(copy.List[0].Child.StringProp, Is.EqualTo(subject.List[0].Child.StringProp));
            Assert.That(copy.List[0].DoubleProp, Is.EqualTo(subject.List[0].DoubleProp));
            Assert.That(copy.List[0].StringProp, Is.EqualTo(subject.List[0].StringProp));
            Assert.That(copy.List[1].Child.StringProp, Is.EqualTo(subject.List[1].Child.StringProp));
            Assert.That(copy.List[1].DoubleProp, Is.EqualTo(subject.List[1].DoubleProp));
            Assert.That(copy.List[1].StringProp, Is.EqualTo(subject.List[1].StringProp));
        }