public async Task MapOperationTypeDescriptors() { // arrange ClientModel clientModel = await CreateClientModelAsync( @" query GetHero { hero(episode: NEW_HOPE) { name appearsIn } } mutation CreateReview { createReview(episode: NEW_HOPE, review: {stars: 5, commentary: ""splendid""}) { stars commentary } } subscription OnReview { onReview(episode: NEW_HOPE) { stars commentary } } "); // act var context = new MapperContext( "Foo.Bar", "FooClient", new Sha1DocumentHashProvider(), RequestStrategyGen.Default, new[] { TransportProfile.Default }); TypeDescriptorMapper.Map(clientModel, context); OperationDescriptorMapper.Map(clientModel, context); // assert Assert.Collection( context.Operations.OrderBy(t => t.Name), operation => { Assert.Equal("CreateReview", operation.Name); }, operation => { Assert.Equal("GetHero", operation.Name); }, operation => { Assert.Equal("OnReview", operation.Name); }); }
public async Task MapOperationTypeDescriptors() { // arrange ClientModel clientModel = await CreateClientModelAsync( @" query GetHero { hero(episode: NEW_HOPE) { name appearsIn } } mutation CreateReview { createReview(episode: NEW_HOPE, review: {stars: 5, commentary: ""splendid""}) { stars commentary } } subscription OnReview { onReview(episode: NEW_HOPE) { stars commentary } } "); // act var context = new MapperContext("Foo.Bar", "FooClient"); TypeDescriptorMapper.Map(clientModel, context); OperationDescriptorMapper.Map(clientModel, context); // assert Assert.Collection( context.Operations.OrderBy(t => t.Name), operation => { Assert.Equal("CreateReviewMutation", operation.Name); }, operation => { Assert.Equal("GetHeroQuery", operation.Name); }, operation => { Assert.Equal("OnReviewSubscription", operation.Name); }); }
public async Task MapClientDescriptor() { // arrange ClientModel clientModel = await CreateClientModelAsync( @" query GetHero { hero(episode: NEW_HOPE) { name appearsIn } } mutation CreateReview { createReview(episode: NEW_HOPE, review: {stars: 5, commentary: ""splendid""}) { stars commentary } } subscription OnReview { onReview(episode: NEW_HOPE) { stars commentary } } "); // act var clientName = "FooClient"; var context = new MapperContext( "Foo.Bar", clientName, new Sha1DocumentHashProvider(), Descriptors.Operations.RequestStrategy.Default, new[] { TransportProfile.Default }); TypeDescriptorMapper.Map(clientModel, context); OperationDescriptorMapper.Map(clientModel, context); ClientDescriptorMapper.Map(clientModel, context); // assert Assert.Equal(clientName, context.Client.Name); Assert.Equal(3, context.Client.Operations.Count); }