示例#1
0
        public async Task Update_Should_Return_Failure_Result_When_There_Is_Issue_While_Saving()
        {
            var testDto = new InterestDTO()
            {
                Id = 1
            };
            var mockInterestsService = new Mock <IInterestService>();

            mockInterestsService.Setup(x => x.UpdateInterest(It.IsAny <InterestDTO>())).ReturnsAsync(Result.Fail(Constants.InterestErrorMessages.Error_Occured_While_Updating_Interest));
            var controller = new InterestController(mockInterestsService.Object);
            var result     = await controller.Update(testDto);

            var contentResult = result as BadRequestObjectResult;

            contentResult.StatusCode.Should().Be(400);
            contentResult.Value.Should().BeAssignableTo <string>();
            var actualValue = contentResult.Value as string;

            actualValue.Should().Be(Constants.InterestErrorMessages.Error_Occured_While_Updating_Interest);
        }
示例#2
0
        public async Task Update_Should_Return_Ok_Result_When_Valid_InterestsDto_Is_Passed()
        {
            var testDto = new InterestDTO()
            {
                Id = 1
            };
            var mockInterestsService = new Mock <IInterestService>();

            mockInterestsService.Setup(x => x.UpdateInterest(It.IsAny <InterestDTO>())).ReturnsAsync(Result.Ok());
            var controller = new InterestController(mockInterestsService.Object);
            var result     = await controller.Update(testDto);

            var contentResult = result as OkObjectResult;

            contentResult.StatusCode.Should().Be(200);
            contentResult.Value.Should().BeAssignableTo <bool>();
            var actualValue = contentResult.Value as bool?;

            actualValue.Should().BeTrue();
        }