Exemple #1
0
 public void Test_Single_Field_And_Dictionary() =>
 CheckNotMatches <Dictionary <int, int> >(ResponseSpecification.Field("A"), "root.[dictionary].A");
Exemple #2
0
 public void Test_Single_Field_Matches() => CheckMatches <Simple_Class>(ResponseSpecification.Field("A"));
Exemple #3
0
 public void Test_Single_Field_And_Int() => CheckNotMatches <int>(ResponseSpecification.Field("A"), "root.A");
Exemple #4
0
 public void Test_Single_Field_And_Array() =>
 CheckNotMatches <int[]>(ResponseSpecification.Field("A"), "root.[list].A");
 public void Test_Duplicate_Field_Names_When_Implicit_Specification_Building()
 {
     Assert.Throws <InvalidOperationException>(() => ResponseSpecification.Create <ClassWithDuplicateFieldName>());
 }
 public void Test_Cyclic_Dependency()
 {
     Assert.Throws <InvalidOperationException>(() => ResponseSpecification.Create <CyclicDependencyRoot>());
 }
        public void Test_Create_For_Simple_Type()
        {
            var actual = ResponseSpecification.Create <SimpleType>();

            actual.ShouldBeEquivalentTo(ResponseSpecification.Field("A").Create());
        }
        public void Test_Contract_With_Ignored_Properties()
        {
            var actual = ResponseSpecification.Create <IgnoredPropertiesClass>();

            actual.ShouldBeEquivalentTo(ResponseSpecification.Field("A").Create());
        }
        public void Test_Array_Of_Array_Of_Nested_Types()
        {
            var actual = ResponseSpecification.Create <NestedType[][]>();

            actual.ShouldBeEquivalentTo(ResponseSpecification.Field("X").Create());
        }
        public void Test_Array_Of_Int()
        {
            var actual = ResponseSpecification.Create <int[]>();

            actual.ShouldBeEquivalentTo(ResponseSpecification.Empty);
        }
        public void Test_Dictionary_Of_Dictionary_Of_Nested_Types()
        {
            var actual = ResponseSpecification.Create <Dictionary <Guid, Dictionary <string, NestedType> > >();

            actual.ShouldBeEquivalentTo(ResponseSpecification.Field("X").Create());
        }
        public void Test_Dictionary_Of_Guids()
        {
            var actual = ResponseSpecification.Create <Dictionary <Guid, Guid> >();

            actual.ShouldBeEquivalentTo(ResponseSpecification.Empty);
        }
        private static IEnumerable <TestCaseData> GenerateTestData()
        {
            yield return(new TestCaseData(
                             ResponseSpecification.Empty,
                             string.Empty
                             ).SetName("Empty"));

            yield return(new TestCaseData(
                             ResponseSpecification.Field("name").Create(),
                             "name"
                             ).SetName("Single field"));

            yield return(new TestCaseData(
                             ResponseSpecification
                             .Field("name1")
                             .Field("name2")
                             .Create(),
                             "name1;name2"
                             ).SetName("Two fields"));

            yield return(new TestCaseData(
                             ResponseSpecification
                             .Field("name1", _ => _.Field("a").Field("b"))
                             .Field("name2", _ => _.Field("d").Field("a"))
                             .Create(),
                             "name1:(a;b);name2:(d;a)"
                             ).SetName("Two fields with nested fields"));

            yield return(new TestCaseData(
                             ResponseSpecification
                             .Field(
                                 "root", root => root
                                 .Field(
                                     "l", l => l
                                     .Field(
                                         "ll", ll => ll
                                         .Field("lll")
                                         .Field("llr")
                                         )
                                     .Field(
                                         "lr", lr => lr
                                         .Field("lrl")
                                         .Field("lrr")
                                         )
                                     )
                                 .Field(
                                     "r", r => r
                                     .Field(
                                         "rl", ll => ll
                                         .Field("rll")
                                         .Field("rlr")
                                         )
                                     .Field(
                                         "rr", lr => lr
                                         .Field("rrl")
                                         .Field("rrr")
                                         )
                                     )
                                 ).Create(),
                             "root:(l:(ll:(lll;llr);lr:(lrl;lrr));r:(rl:(rll;rlr);rr:(rrl;rrr)))"
                             ).SetName("Binary tree"));
        }