public void CheckAssumptionsTestFooDefault()
        {
            var data = TestFoo.GetDefaultFoo();

            Assert.AreEqual(_numberOfBars, data.Bars.Count(), nameof(_numberOfBars));
            Assert.AreEqual(_numberOfBazes, data.Bars.Sum(c => c.Bazes.Count()), nameof(_numberOfBazes));
        }
Beispiel #2
0
        public void ShouldExcludeRakatakaMyPropertyWithClientProjection(Projection projection, int myPropertyNumberOccurences)
        {
            var json = _subject.Serialize(TestFoo.GetDefaultFoo(), projection);

            Regex regex   = new Regex(nameof(Baz.MyProperty), RegexOptions.IgnoreCase);
            var   matches = regex.Matches(json);

            Assert.AreEqual(myPropertyNumberOccurences, matches.Count);
        }
Beispiel #3
0
        public void ShouldUseJsonPropertyNameOnCustomConverter()
        {
            var json = _subject.Serialize(TestFoo.GetDefaultFoo(), Projection.Client);

            Regex regex = new Regex(
                "RenamedProperty",
                RegexOptions.IgnoreCase
                );
            var matches = regex.Matches(json);

            Assert.AreEqual(4, matches.Count(), nameof(matches));
        }
Beispiel #4
0
        public void ShouldIgnoreJsonIgnoreClassLevelPropertiesWithCustomConverter(string propertyName)
        {
            var json = _subject.Serialize(TestFoo.GetDefaultFoo(), Projection.Client);

            Regex regex = new Regex(
                propertyName,
                RegexOptions.IgnoreCase
                );
            var matches = regex.Matches(json);

            Assert.AreEqual(0, matches.Count(), nameof(matches));
        }
Beispiel #5
0
        public void ShouldNotPrintBazPropertyWhenBarPropertySet()
        {
            const int expectedCount = 2;
            var       json          = _subject.Serialize(TestFoo.GetDefaultFoo(), Projection.Client);
            var       propertyName  = nameof(Baz.ShouldIncludeWhenBarSpecifies);

            Regex regex = new Regex(
                propertyName,
                RegexOptions.IgnoreCase
                );
            var matches = regex.Matches(json);

            Assert.AreEqual(expectedCount, matches.Count(), nameof(matches));
        }
        public void ShouldContainCorrectNumberOfNestedObjects()
        {
            const int numberOfBars  = 2;
            const int numberOfBazes = 4;

            var json = new JsonConverterFooSerializer(new JsonConvertersFactory()).Serialize(TestFoo.GetDefaultFoo(), Projection.None);
            FooDeserializer <Foo> fd = new FooDeserializer <Foo>();

            var result = fd.Deserialize(json);

            Assert.AreEqual(numberOfBars, result.Bars.Count(), nameof(numberOfBars));
            Assert.AreEqual(numberOfBazes, result.Bars.Sum(c => c.Bazes.Count()), nameof(numberOfBazes));
        }