public async Task UpdateServiceTypeAsync_Throws_NotFoundException() { //Arrange var id = 201; _fixture.MockServiceTypeService.Setup(x => x.GetServiceTypeAsync(It.IsAny <Expression <Func <ServiceType, bool> > >())) .Returns <Expression <Func <ServiceType, bool> > >(expression => Task.FromResult(_fixture.ServiceTypes.AsQueryable().FirstOrDefault(expression))); _fixture.MockServiceTypeService.Setup(x => x.UpdateServiceTypeAsync(It.IsAny <ServiceType>())); var repository = new ServiceTypeRepository(AutoMapperSingleton.Mapper, _fixture.MockServiceTypeService.Object); //Act var exception = await Assert.ThrowsAsync <RestException>(() => repository.UpdateServiceTypeAsync(id, _fixture.EditServiceTypeDto)); //Assert exception.ErrorCode.Should().Be(HttpStatusCode.NotFound); exception.ErrorMessage.Should().Be("Service type not found."); exception.ErrorType.Should().Be(HttpStatusCode.NotFound.ToString()); }
public async Task UpdateServiceTypeAsync_Returns_Updated_GetServiceTypeDto() { //Arrange var id = 1; _fixture.MockServiceTypeService.Setup(x => x.GetServiceTypeAsync(It.IsAny <Expression <Func <ServiceType, bool> > >())) .Returns <Expression <Func <ServiceType, bool> > >(expression => Task.FromResult(_fixture.ServiceTypes.AsQueryable().FirstOrDefault(expression))); _fixture.MockServiceTypeService.Setup(x => x.UpdateServiceTypeAsync(It.IsAny <ServiceType>())); var repository = new ServiceTypeRepository(AutoMapperSingleton.Mapper, _fixture.MockServiceTypeService.Object); //Act var result = await repository.UpdateServiceTypeAsync(id, _fixture.EditServiceTypeDto); //Assert result.Should().BeOfType(typeof(GetServiceTypeDto)); result.Id.Should().Be(id); result.Type.Should().Be(_fixture.EditServiceTypeDto.Type); }