public void Should_ReturnError_If_BrandName_AlreadyExists_OnAdd() { BrandRepository.Setup(r => r.GetByName(It.IsAny <string>())).Returns(NewValidBrand); var service = new VehicleService(UoW.Object, BrandRepository.Object); var result = service.AddBrand(NewValidBrand); Assert.False(result.Success); Assert.Single(result.Errors); }
public void Should_AddBrand_Success() { BrandRepository.Setup(r => r.Add(It.IsAny <Brand>())).Returns(NewValidBrand); UoW.Setup(u => u.Commit()).Returns(true); var service = new VehicleService(UoW.Object, BrandRepository.Object); var result = service.AddBrand(NewValidBrand); Assert.True(result.Success); }
public void Should_ReturnErrorOnSaveThrows() { BrandRepository.Setup(r => r.Add(It.IsAny <Brand>())).Returns(NewValidBrand); UoW.Setup(u => u.Commit()).Throws(new Exception("DataBase Error")); var service = new VehicleService(UoW.Object, BrandRepository.Object); var result = service.AddBrand(NewValidBrand); Assert.False(result.Success); Assert.Single(result.Errors); }