Beispiel #1
0
        public async Task Should_return_invalid_result(int[] numbers, int result)
        {
            // arrange
            CalculationSourceGenerator
            .GetSumSource()
            .Returns(new SumsSource
            {
                Numbers       = numbers,
                IsValidResult = false
            });

            // act
            var httpResponse = await TestServer.Value
                               .CreateRequest(SumsBaseUrl)
                               .GetAsync();

            // assert
            httpResponse.StatusCode.Should().Be(HttpStatusCode.OK);

            var results = await Deserialize <Response <SumsResult>[]>(httpResponse);

            results.Length.Should().Be(16);
            foreach (var response in results)
            {
                response.Set.Numbers.Should().BeEquivalentTo(numbers);
                response.Set.IsValidResult.Should().BeFalse();
                response.Set.Result.Should().NotBe(result);
            }
            ;
        }
Beispiel #2
0
        public async Task Should_return_valid_result(int[] numbers, int result)
        {
            // arrange
            CalculationSourceGenerator
            .GetSumSource()
            .Returns(new SumsSource
            {
                Numbers       = numbers,
                IsValidResult = true
            });

            var expected = Enumerable.Range(0, 16)
                           .Select(_ => new Response <SumsResult>
            {
                Set = new SumsResult
                {
                    Numbers       = numbers,
                    IsValidResult = true,
                    Result        = result
                }
            });

            // act
            var httpResponse = await TestServer.Value
                               .CreateRequest(SumsBaseUrl)
                               .GetAsync();

            // assert
            httpResponse.StatusCode.Should().Be(HttpStatusCode.OK);

            var sums = await Deserialize <Response <SumsResult>[]>(httpResponse);

            sums.Should().BeEquivalentTo(expected);
        }