public void SimpleDecodeTest()
        {
            const string json = "{\"data\":{\"indexed1\":\"test1\",\"indexed2\":\"test2\"}}";

            IsolationUtils.FakeAttributeClient <ReferenceModel>(SimpleDecodeTest_Run, json);
            IsolationUtils.FakeManualClient <ReferenceModel>(SimpleDecodeTest_Run, json);
        }
        public void ReferenceTypeWithAllPrimitivesDecodeTest()
        {
            var dict = new Dictionary <string, object>
            {
                { "string_val", "test1" },
                { "int_val", 234 },
                { "boolean_val", true },
                { "byte_val", 10 },
                { "long_val", 123 },
                { "float_val", 234.5f },
                { "double_val", 123.4 },
                { "date_time_val", new TimeStampV(new DateTime(2010, 1, 1)) },
                { "short_val", 5 },
                { "u_short_val", 3 },
                { "u_int_val", 2 },
                { "u_long_val", 4 }, // bizarre issue with conversion, ulong will implicit to double for some reason
                { "s_byte_val", 1 },
                { "char_val", "a" },
            };

            var json = JsonConvert.SerializeObject(new { data = dict });

            IsolationUtils.FakeAttributeClient <PrimitivesReferenceModel>(ReferenceTypeWithAllPrimitivesDecodeTest_Run, json);
            IsolationUtils.FakeManualClient <PrimitivesReferenceModel>(ReferenceTypeWithAllPrimitivesDecodeTest_Run, json);
        }
        public void CustomCollectionDecodeTest()
        {
            const string json = "{\"data\": {\"custom_collection\": [\"test1\",\"test2\"]}}";

            IsolationUtils.FakeAttributeClient <SupportedCustomCollectionModel>(CustomCollectionDecodeTest_Run, json);
            IsolationUtils.FakeManualClient <SupportedCustomCollectionModel>(CustomCollectionDecodeTest_Run, json);
        }
        public void CustomCollectionDecodeTest2()
        {
            var datesJson = JsonConvert.SerializeObject(new[] { new TimeStampV(DateTime.MinValue), new TimeStampV(DateTime.MaxValue) });
            var json      = "{\"data\": {\"custom_collection\": " + datesJson + ", \"dates_array\": " + datesJson + "}}";

            IsolationUtils.FakeAttributeClient <SupportedCustomCollectionModel2>(CustomCollectionDecodeTest2_Run, json);
            IsolationUtils.FakeManualClient <SupportedCustomCollectionModel2>(CustomCollectionDecodeTest2_Run, json);
        }
        public void NamedPropertyModelDecodeTest()
        {
            var dict = new Dictionary <string, object>
            {
                { "not_a_test_string", "test123" }
            };

            var json = JsonConvert.SerializeObject(new { data = dict });

            IsolationUtils.FakeAttributeClient <NamedPropertyModel>(NamedPropertyModelDecodeTest_Run, json);
            IsolationUtils.FakeManualClient <NamedPropertyModel>(NamedPropertyModelDecodeTest_Run, json);
        }
        public void ReferenceTypeWithReferenceTypesDecodeTest()
        {
            var referenceModelDict1 = new Dictionary <string, object>
            {
                { "indexed2", "test2" }
            };
            var referenceModelDict2 = new Dictionary <string, object>
            {
                { "indexed2", "test4" }
            };
            var referenceModelDict3 = new Dictionary <string, object>
            {
                { "indexed2", "test6" }
            };
            var referenceModelDict4 = new Dictionary <string, object>
            {
                { "indexed2", "test8" }
            };
            var referenceModelDict5 = new Dictionary <string, object>
            {
                { "indexed2", "test10" }
            };
            var dict = new Dictionary <string, object>
            {
                { "reference_model", new { @ref = "test1", data = referenceModelDict1 } },
                {
                    "reference_models1",
                    new List <object>
                    {
                        new { @ref = "test3", data = referenceModelDict2 },
                        new { @ref = "test5", data = referenceModelDict3 }
                    }
                },
                {
                    "reference_models2",
                    new[]
                    {
                        new { @ref = "test7", data = referenceModelDict4 },
                        new { @ref = "test9", data = referenceModelDict5 }
                    }
                }
            };

            var json = JsonConvert.SerializeObject(new { data = dict });

            IsolationUtils.FakeAttributeClient <ReferenceTypesReferenceModel>(ReferenceTypeWithReferenceTypesDecodeTest_Run, json);
            IsolationUtils.FakeManualClient <ReferenceTypesReferenceModel>(ReferenceTypeWithReferenceTypesDecodeTest_Run, json);
        }
        private static void MockManualContext(IsolationUtils.TestAction action, string returns = null)
        {
            var  clientMock = new Mock <IFaunaClient>();
            var  context    = IsolationUtils.CreateMappingContext(clientMock.Object);
            Expr lastQuery  = null;

            clientMock.Setup(a => a.Query(It.IsAny <Expr>())).Returns((Expr q) =>
            {
                lastQuery = q;
                return(Task.FromResult(new RequestResult(
                                           HttpMethod.Get,
                                           "",
                                           new Dictionary <string, string>(),
                                           "",
                                           returns,
                                           400,
                                           new Dictionary <string, IEnumerable <string> >(),
                                           DateTime.Now,
                                           DateTime.Now
                                           )));
            });

            action(context, ref lastQuery);
        }
Beispiel #8
0
 public void TupleBuiltInMethodTest()
 {
     IsolationUtils.FakeAttributeClient(TupleBuiltInMethodTest_Run);
     IsolationUtils.FakeManualClient(TupleBuiltInMethodTest_Run);
 }
 public void BasicReferenceTypeSerializationTest()
 {
     IsolationUtils.FakeAttributeClient(BasicReferenceTypeSerializationTest_Run);
     IsolationUtils.FakeManualClient(BasicReferenceTypeSerializationTest_Run);
 }
Beispiel #10
0
 public void DateTimePaginateTest()
 {
     IsolationUtils.FakeAttributeClient(DateTimePaginateTest_Run);
     IsolationUtils.FakeManualClient(DateTimePaginateTest_Run);
 }
Beispiel #11
0
 public void ConditionalQueryTest()
 {
     IsolationUtils.FakeAttributeClient(ConditionalQueryTest_Run);
     IsolationUtils.FakeManualClient(ConditionalQueryTest_Run);
 }
Beispiel #12
0
 public void SelectReferenceQueryTest()
 {
     IsolationUtils.FakeAttributeClient(SelectReferenceQueryTest_Run);
     IsolationUtils.FakeManualClient(SelectReferenceQueryTest_Run);
 }
Beispiel #13
0
 public static void CustomDbFunctionTest()
 {
     IsolationUtils.FakeAttributeClient(CustomDbFunctionTest_Run);
     IsolationUtils.FakeManualClient(CustomDbFunctionTest_Run);
 }
 public void ReferenceTypeWithValueTypesTest()
 {
     IsolationUtils.FakeAttributeClient(ReferenceTypeWithValueTypesTest_Run);
     IsolationUtils.FakeManualClient(ReferenceTypeWithValueTypesTest_Run);
 }
Beispiel #15
0
 public void IncludeQueryTest()
 {
     IsolationUtils.FakeAttributeClient(IncludeQueryTest_Run);
     IsolationUtils.FakeManualClient(IncludeQueryTest_Run);
 }
Beispiel #16
0
 public void TypeCheckQueryTest()
 {
     IsolationUtils.FakeAttributeClient(TypeCheckQueryTest_Run);
     IsolationUtils.FakeManualClient(TypeCheckQueryTest_Run);
 }
Beispiel #17
0
 public void ArrayInitQueryTest()
 {
     IsolationUtils.FakeAttributeClient(ArrayInitQueryTest_Run);
     IsolationUtils.FakeManualClient(ArrayInitQueryTest_Run);
 }
Beispiel #18
0
 public void DefaultValueQueryTest()
 {
     IsolationUtils.FakeAttributeClient(DefaultValueQueryTest_Run);
     IsolationUtils.FakeManualClient(DefaultValueQueryTest_Run);
 }
Beispiel #19
0
 public void FromRefPaginateTest()
 {
     IsolationUtils.FakeAttributeClient(FromRefPaginateTest_Run);
     IsolationUtils.FakeManualClient(FromRefPaginateTest_Run);
 }
Beispiel #20
0
 public void SelectValueTypePropertyTest()
 {
     IsolationUtils.FakeAttributeClient(SelectValueTypePropertyTest_Run);
     IsolationUtils.FakeManualClient(SelectValueTypePropertyTest_Run);
 }
Beispiel #21
0
 public void CustomQueryTest()
 {
     IsolationUtils.FakeAttributeClient(CustomQueryTest_Run);
     IsolationUtils.FakeManualClient(CustomQueryTest_Run);
 }
Beispiel #22
0
 public void DistinctQueryTest()
 {
     IsolationUtils.FakeAttributeClient(DistinctQueryTest_Run);
     IsolationUtils.FakeManualClient(DistinctQueryTest_Run);
 }
 public void NamedPropertyModelEncodeTest()
 {
     IsolationUtils.FakeAttributeClient(NamedPropertyModelEncodeTest_Run);
     IsolationUtils.FakeManualClient(NamedPropertyModelEncodeTest_Run);
 }
Beispiel #24
0
 public void SortDirectionPaginateTest()
 {
     IsolationUtils.FakeAttributeClient(SortDirectionPaginateTest_Run);
     IsolationUtils.FakeManualClient(SortDirectionPaginateTest_Run);
 }
Beispiel #25
0
 public void LocalListInitTest()
 {
     IsolationUtils.FakeAttributeClient(LocalListInitTest_Run);
     IsolationUtils.FakeManualClient(LocalListInitTest_Run);
 }
Beispiel #26
0
 public void NewObjectQueryTest()
 {
     IsolationUtils.FakeAttributeClient(NewObjectQueryTest_Run);
     IsolationUtils.FakeManualClient(NewObjectQueryTest_Run);
 }
 public void SerializationFailureTest()
 {
     IsolationUtils.FakeAttributeClient(SerializationFailureTest_Run);
     IsolationUtils.FakeManualClient(SerializationFailureTest_Run);
 }
Beispiel #28
0
 public void LocalMethodCallTest()
 {
     IsolationUtils.FakeAttributeClient(LocalMethodCallTest_Run);
     IsolationUtils.FakeManualClient(LocalMethodCallTest_Run);
 }
Beispiel #29
0
 public void QueryFailureTest()
 {
     IsolationUtils.FakeAttributeClient(QueryFailureTest_Run);
     IsolationUtils.FakeManualClient(QueryFailureTest_Run);
 }
Beispiel #30
0
 public void SkipTakeQueryTest()
 {
     IsolationUtils.FakeAttributeClient(SkipTakeQueryTest_Run);
     IsolationUtils.FakeManualClient(SkipTakeQueryTest_Run);
 }