コード例 #1
0
        public async Task GetCalculationByCalculationSpecificationId_GivenACalculationIsNotFound_ShouldReturnNotFoundObjectResult()
        {
            //Arrange
            const string calcSpecId = "CalcSpecId";

            ICalculationsRepository mockCalculationRepository = Substitute.For <ICalculationsRepository>();

            mockCalculationRepository
            .GetCalculationByCalculationSpecificationId(calcSpecId)
            .Returns(Task.FromResult((Calculation)null));

            CalculationService service = CreateCalculationService(calculationsRepository: mockCalculationRepository);

            //Act
            IActionResult result = await service.GetCalculationByCalculationSpecificationId(calcSpecId);

            //Assert
            result
            .Should()
            .BeOfType <NotFoundObjectResult>();
        }