public void Object_is_correctly_serialized(JsonConfigurationSerializer sut, ObjectWithInnerObject testSource, string rootSectionName)
        {
            var result = sut.Serialize(testSource, rootSectionName);

            Assert.That(result, Contains.Key($"{rootSectionName}:{nameof(testSource.InnerObject)}:{nameof(testSource.InnerObject.Text)}"));
            Assert.That(result, Contains.Key($"{rootSectionName}:{nameof(testSource.InnerObject)}:{nameof(testSource.InnerObject.Value)}"));

            Assert.That(result[$"{rootSectionName}:{nameof(testSource.InnerObject)}:{nameof(testSource.InnerObject.Text)}"], Is.EqualTo(testSource.InnerObject.Text));
            Assert.That(result[$"{rootSectionName}:{nameof(testSource.InnerObject)}:{nameof(testSource.InnerObject.Value)}"], Is.EqualTo($"{testSource.InnerObject.Value}"));
        }
コード例 #2
0
        public NullConditionalOperatorTests()
        {
            this.nullConditionalOperator = new NullConditionalOperator();

            this.nonNullInnerObject = new ObjectWithInnerObject<ObjectWithInnerObject<ObjectWithInnerObject<string>>>
            {
                InnerObject = new ObjectWithInnerObject<ObjectWithInnerObject<string>>
                {
                    InnerObject = new ObjectWithInnerObject<string>
                    {
                        InnerObject = "Some value"
                    }
                }
            };

            this.nullInnerObject = new ObjectWithInnerObject<ObjectWithInnerObject<ObjectWithInnerObject<string>>>
            {
                InnerObject = new ObjectWithInnerObject<ObjectWithInnerObject<string>>()
            };
        }