public void WhenShopDtoIsNullThenReturnNotSuccessfull() { var shopConfigurationService = new ShopConfigurationService(Mock.Of <IShopRepository>()); var serviceActionResult = shopConfigurationService.AddNewShop(null); serviceActionResult.Status.Should().Be(ActionStatus.NotSuccessfull); }
public void WhenShopIsNullThenEditShopReturnsNotSuccessfull() { var shopConfigurationService = new ShopConfigurationService(Mock.Of <IShopRepository>()); var result = shopConfigurationService.EditShop(null); result.Status.Should().Be(ActionStatus.NotSuccessfull); }
public void WhenShopExistsThenUpdateShopAndReturnSuccessfull() { var shopRepository = new Mock <IShopRepository>(); shopRepository.Setup(r => r.GetShopById(new Guid("{4BA29681-3FA1-431E-8C98-12E3B952BA25}"))).Returns(new Shop()); var shopConfigurationService = new ShopConfigurationService(shopRepository.Object); ServiceActionResult actionResult = shopConfigurationService.ShopActivation(new Guid("{4BA29681-3FA1-431E-8C98-12E3B952BA25}"), It.IsAny <bool>()); actionResult.Should().Be(ServiceActionResult.Successfull); }
public void WhenShopDoesNotExistsThenReturnNotSuccessfull() { var shopRepository = new Mock <IShopRepository>(); shopRepository.Setup(r => r.GetShopById(It.IsAny <Guid>())).Returns((Shop)null); var shopConfigurationService = new ShopConfigurationService(shopRepository.Object); ServiceActionResult actionResult = shopConfigurationService.ShopActivation(It.IsAny <Guid>(), It.IsAny <bool>()); actionResult.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 WhenShopNotFoundThenEditShopReturnsNotSuccessfull() { var shopRepository = new Mock <IShopRepository>(); shopRepository.Setup(r => r.GetShopById(It.IsAny <Guid>())).Returns((Shop)null); var shopConfigurationService = new ShopConfigurationService(shopRepository.Object); var result = shopConfigurationService.EditShop(new ShopDto()); result.Status.Should().Be(ActionStatus.NotSuccessfull); }
public void WhenExceptionCatchedThenReturnWithExceptionStatus() { var shopRepository = new Mock <IShopRepository>(); shopRepository.Setup(r => r.GetShopById(new Guid("{4BA29681-3FA1-431E-8C98-12E3B952BA25}"))).Throws <Exception>(); var shopConfigurationService = new ShopConfigurationService(shopRepository.Object); ServiceActionResult actionResult = shopConfigurationService.ShopActivation(new Guid("{4BA29681-3FA1-431E-8C98-12E3B952BA25}"), It.IsAny <bool>()); actionResult.Status.Should().Be(ActionStatus.WithException); }
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 WhenShopFoundButExceptionOccuredThenEditShopReturnWithExceptionStatus() { var shopRepository = new Mock <IShopRepository>(); shopRepository.Setup(r => r.GetShopById(new Guid("{4BA29681-3FA1-431E-8C98-12E3B952BA25}"))).Returns(new Shop()); var shopConfigurationService = new ShopConfigurationService(shopRepository.Object); ServiceActionResult actionResult = shopConfigurationService.EditShop(new ShopDto() { ShopGuid = new Guid("{4BA29681-3FA1-431E-8C98-12E3B952BA25}"), Address = new UserAddressDto() }); actionResult.Status.Should().Be(ActionStatus.WithException); }
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); }