public void NestedQuery_Select_Multiple_Members_To_Named_Class() { var expression = new RootQuery() .Nested("foo") .Simple("bar") .Select(x => new NamedClass { Name = x.Name, Description = x.Description, }); var data = @"{ ""data"":{ ""nested"": { ""simple"":{ ""name"": ""Hello World!"", ""description"": ""Goodbye cruel world"" } } } }"; var query = new QueryBuilder().Build(expression); var expectedType = expression.GetType().GetGenericArguments()[0]; var result = new ResponseDeserializer().Deserialize(query, data).Single(); Assert.IsType(expectedType, result); Assert.Equal("Hello World!", result.Name); Assert.Equal("Goodbye cruel world", result.Description); }
public void SimpleQuery_Select_Single_Member() { var query = new RootQuery() .Simple("foo") .Select(x => x.Name); var data = @"{ ""data"":{ ""simple"":{ ""name"": ""Hello World!"" } } }"; var operation = new QueryBuilder().Build(query); var expectedType = query.GetType().GetGenericArguments()[0]; var result = new ResponseDeserializer().Deserialize(operation, data).Single(); Assert.IsType(expectedType, result); Assert.Equal("Hello World!", result); }