Ejemplo n.º 1
0
        public void WhenShopDtoIsNullThenReturnNotSuccessfull()
        {
            var shopConfigurationService = new ShopConfigurationService(Mock.Of <IShopRepository>());

            var serviceActionResult = shopConfigurationService.AddNewShop(null);

            serviceActionResult.Status.Should().Be(ActionStatus.NotSuccessfull);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }