diff --git a/src/FairyBread.Tests/InputValidationMiddlewareTests.cs b/src/FairyBread.Tests/InputValidationMiddlewareTests.cs index 294f238..ee3ff19 100644 --- a/src/FairyBread.Tests/InputValidationMiddlewareTests.cs +++ b/src/FairyBread.Tests/InputValidationMiddlewareTests.cs @@ -120,30 +120,51 @@ public async Task Mutation_Validates_By_Default() await Verifier.Verify(result); } - // TODO: Fix - //[Fact] - //public async Task Multi_TopLevelFields_And_MultiRuns_Works() - //{ - // // Arrange - // var executor = await GetRequestExecutorAsync(options => - // { - // options.ShouldValidate = (ctx, arg) => ctx.Operation.Operation == OperationType.Query; - // }); - - // var query = @" - // query { - // read(foo: { someInteger: -1, someString: ""hello"" }) - // read(foo: { someInteger: -1, someString: ""hello"" }) - // }"; - - // // Act - // var result1 = await executor.ExecuteAsync(query); - // var result2 = await executor.ExecuteAsync(query); - // var result3 = await executor.ExecuteAsync(query); - - // // Assert - // await Verifier.Verify(new { result1, result2, result3 }); - //} + [Fact] + public async Task Multi_TopLevelFields_And_MultiRuns_Works() + { + // Arrange + var executor = await GetRequestExecutorAsync(options => + { + options.ShouldValidate = (ctx, arg) => ctx.Operation.Operation == OperationType.Query; + }); + + var query = @" + query { + read(foo: { someInteger: -1, someString: ""hello"" }) + read(foo: { someInteger: -1, someString: ""hello"" }) + }"; + + // Act + IExecutionResult result1; + using (executor.Services.CreateScope()) + { + result1 = await executor.ExecuteAsync(query); + } + + IExecutionResult result2; + using (executor.Services.CreateScope()) + { + executor = await GetRequestExecutorAsync(options => + { + options.ShouldValidate = (ctx, arg) => ctx.Operation.Operation == OperationType.Query; + }); + result2 = await executor.ExecuteAsync(query); + } + + IExecutionResult result3; + using (executor.Services.CreateScope()) + { + executor = await GetRequestExecutorAsync(options => + { + options.ShouldValidate = (ctx, arg) => ctx.Operation.Operation == OperationType.Query; + }); + result3 = await executor.ExecuteAsync(query); + } + + // Assert + await Verifier.Verify(new { result1, result2, result3 }); + } [Fact] public async Task Ignores_Null_Argument_Value()