Example #1
0
        private async Task ExecuteOperation(OperationType operationType)
        {
            await _fixture.StartAsync();

            var operation = new SimpleArithmeticOperation(operationType)
            {
                FirstNumber  = _context.Get <decimal>(FirstNumber),
                SecondNumber = _context.Get <decimal>(SecondNumber),
            };

            var request = new HttpRequestMessage(HttpMethod.Post, "/api/calculator")
            {
                Content = new StringContent(
                    JsonSerializer.Serialize(operation,
                                             options: new JsonSerializerOptions
                {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                    Converters           = { new JsonStringEnumConverter() }
                }),
                    Encoding.UTF8, "application/json")
            };
            var response = await _fixture.FunctionInstance.Run(request);

            var successfulResponse = response as OkObjectResult;

            Assert.NotNull(successfulResponse);

            var result = successfulResponse.Value as SimpleArithmeticOperationResult;

            Assert.NotNull(result);

            _context.Add(Result, result.Result);
        }
 protected override IOperationResult InternalOperation(SimpleArithmeticOperation operation)
 {
     return(new SimpleArithmeticOperationResult(operation.FirstNumber - operation.SecondNumber));
 }