public void WhenShopDtoIsNullThenReturnNotSuccessfull() { var shopConfigurationService = new ShopConfigurationService(Mock.Of <IShopRepository>()); var serviceActionResult = shopConfigurationService.AddNewShop(null); serviceActionResult.Status.Should().Be(ActionStatus.NotSuccessfull); }
public void WhenShopAlreadyExistThenReturnNotSuccessfullActionResult() { var shopConfigurationService = new ShopConfigurationService(Mock.Of <IShopRepository>(r => r.GetShopByName("shopName") == new Shop())); var shopDto = new ShopDto() { Name = "shopName" }; ServiceActionResult serviceActionResult = shopConfigurationService.AddNewShop(shopDto); serviceActionResult.Status.Should().Be(ActionStatus.NotSuccessfull); }
public void WhenShopNameDoesntExistThenSuccessfullActionResultIsReturned() { var repositoryMock = new Mock <IShopRepository>(); repositoryMock.Setup(r => r.GetShopByName("shopName")).Returns((Shop)null); var shopConfigurationService = new ShopConfigurationService(repositoryMock.Object); var shopDto = new ShopDto() { Name = "shopName" }; ServiceActionResult serviceActionResult = shopConfigurationService.AddNewShop(shopDto); serviceActionResult.Status.Should().Be(ActionStatus.Successfull); }
public void WhenAddToDatabaseThrowExceptionThenStatusWithExceptionIsReturned() { var shopRepository = new Mock <IShopRepository>(); shopRepository.Setup(r => r.GetShopByName(It.IsAny <string>())).Returns((Shop)null); shopRepository.Setup(r => r.AddToDatabase(It.IsAny <Shop>())).Throws <Exception>(); var shopConfigurationService = new ShopConfigurationService(shopRepository.Object); var shopDto = new ShopDto() { Name = "shopName" }; ServiceActionResult serviceActionResult = shopConfigurationService.AddNewShop(shopDto); serviceActionResult.Status.Should().Be(ActionStatus.WithException); }