public void reads_query_without_corellation_id_in_aggregated_query_reader()
        {
            var json = JsonUtil.ToJson(new
            {
                queries = new[]
                {
                    new
                    {
                        type  = "query-1",
                        query = new
                        {
                            name = "Joe"
                        }
                    }
                }
            });

            var messageTypes = TestHost.Service <IClientMessageCache>();

            var readQuery = new AggregatedQueryReader().Read(new JsonSerializer(), messageTypes, json);

            readQuery.ShouldNotBeNull();
            readQuery.queries[0].type.ShouldBe("query-1");
            readQuery.queries[0].query.ShouldBeOfType <AggregationEndpoint.Query1>()
            .Name.ShouldBe("Joe");
            readQuery.queries[0].correlationId.ShouldBeNull();
        }
        public void use_aggregated_query_reader()
        {
            var query = new AggregatedQuery();

            query.AddQuery(new AggregationEndpoint.Query1 {
                Name = "Jeremy Maclin"
            });
            query.Resource <AggregationEndpoint.Resource2>();
            query.AddQuery(new AggregationEndpoint.Input2());
            query.Resource <AggregationEndpoint.Resource4>();

            var json = JsonUtil.ToJson(query);

            var messageTypes = TestHost.Service <IClientMessageCache>();

            var readQuery = new AggregatedQueryReader().Read(new JsonSerializer(), messageTypes, json);

            readQuery.ShouldNotBeNull();
            readQuery.queries[0].type.ShouldBe("query-1");
            readQuery.queries[0].query.ShouldBeOfType <AggregationEndpoint.Query1>()
            .Name.ShouldBe("Jeremy Maclin");

            readQuery.queries[1].type.ShouldBe("resource-2");
            readQuery.queries[2].type.ShouldBe("input-2");
            readQuery.queries[3].query.ShouldBeNull();
        }
        public void use_aggregated_query_reader()
        {
            var query = new AggregatedQuery();
            query.AddQuery(new AggregationEndpoint.Query1 { Name = "Jeremy Maclin" });
            query.Resource<AggregationEndpoint.Resource2>();
            query.AddQuery(new AggregationEndpoint.Input2());
            query.Resource<AggregationEndpoint.Resource4>();

            var json = JsonUtil.ToJson(query);

            var messageTypes = TestHost.Service<IClientMessageCache>();

            var readQuery = new AggregatedQueryReader().Read(new JsonSerializer(), messageTypes, json);

            readQuery.ShouldNotBeNull();
            readQuery.queries[0].type.ShouldEqual("query-1");
            readQuery.queries[0].query.ShouldBeOfType<AggregationEndpoint.Query1>()
                .Name.ShouldEqual("Jeremy Maclin");

            readQuery.queries[1].type.ShouldEqual("resource-2");
            readQuery.queries[2].type.ShouldEqual("input-2");
            readQuery.queries[3].query.ShouldBeNull();
        }
        public void reads_query_without_corellation_id_in_aggregated_query_reader()
        {
            var json = JsonUtil.ToJson(new
            {
                queries = new[]
                {
                    new
                    {
                        type = "query-1",
                        query = new
                        {
                            name = "Joe"
                        }
                    }
                }
            });

            var messageTypes = TestHost.Service<IClientMessageCache>();

            var readQuery = new AggregatedQueryReader().Read(new JsonSerializer(), messageTypes, json);

            readQuery.ShouldNotBeNull();
            readQuery.queries[0].type.ShouldBe("query-1");
            readQuery.queries[0].query.ShouldBeOfType<AggregationEndpoint.Query1>()
                .Name.ShouldBe("Joe");
            readQuery.queries[0].correlationId.ShouldBeNull();
        }