public void exec_ServiceFunctionWithOneComplexParameter() { // Arrange TestCaseTesterController controller = new TestCaseTesterController(); TestCaseTesterComplexP p = new TestCaseTesterComplexP(); //p.MFieldbytearray50 p.MFielddatetime = new DateTime(2013, 1, 1); p.MFielddecimal = 1000000; p.MFielddouble = Double.MaxValue; p.MFieldfloat = float.MaxValue; p.MFieldint16 = Int16.MaxValue; p.MFieldint32 = Int32.MaxValue; p.MFieldint64 = Int64.MaxValue; p.MFieldntext = "Some Text"; p.MFieldstring = "Some String"; string jSonData = FWUtils.EntityUtils.JsonSerializeObject(p); FWPostBody body = new FWPostBody(jSonData); // Act ServiceActionResult res = controller.Exec("ServiceFunctionWithOneComplexParameter", body); // Assert Assert.AreEqual("OK!", res.data); }
public ActionResult EditProductCategory(ProductCategoryViewModel productCategory) { if (!ModelState.IsValid) { return(EditCategory(productCategory.ProductCategoryGuid)); } ProductCategoryDto productCategoryDto = productCategory.Map(); Guid shopGuid; if (!Session.TryGetKey(SessionKeys.ShopAdminSelectedShopGuid, out shopGuid)) { return(View("ShopNotFound")); } productCategoryDto.ShopGuid = shopGuid; ServiceActionResult actionResult = _productCategoryService.EditProductCategory(productCategoryDto); if (actionResult.Status != ActionStatus.Successfull) { return(EditCategory(productCategory.ProductCategoryGuid)); } return(RedirectToMainView()); }
public static ServiceActionResult <TStatus, TClone> CloneWithMapping <TStatus, TContent, TClone>( this ServiceActionResult <TStatus, TContent> result, TClone newContent) { var mappingResult = Mapper.Map(result.Content, newContent); return(new ServiceActionResult <TStatus, TClone>(result.Status, mappingResult)); }
public ActionResult OrderBasket() { var shopGuid = Session[SessionKeys.ClientSelectedShopGuid]; if (shopGuid == null) { return(View("~/Views/ClientCore/ShopNotFound.cshtml")); } Guid parsedShopGuid; if (!Guid.TryParse(shopGuid.ToString(), out parsedShopGuid)) { return(View("~/Views/ClientCore/ShopNotFound.cshtml")); } BasketDto basket = _basketRepositoryService.GetShopBasketForClient(parsedShopGuid, User.Identity.Name); if (basket.Equals(BasketDto.EmptyBasket)) { return(View("BasketNotFound")); } ServiceActionResult result = _orderService.FinalizeOrder(basket.BasketGuid); if (result.Status == ActionStatus.Successfull) { return(View("OrderFinalized")); } return(View("UnexpectedError", result)); }
public void WhenSpecifiedShopDoesntExistThenReturnNotSuccessfullActionResult() { var service = new UserAssignmentService(Mock.Of <IShopRepository>(), Mock.Of <IUserRepository>(r => r.GetUserByLogin("testLogin") == new User("testLogin", "testPassword", UserRank.Client))); ServiceActionResult result = service.AssignUserToShop(Guid.Empty, Guid.Parse("5d3e3599-5e38-44e7-a0d9-84abef706163")); result.Status.Should().Be(ActionStatus.NotSuccessfull); }
public void WhenUserToAssignDoesntExistThenReturnNotSuccessfullAcionResult() { var service = new UserAssignmentService(Mock.Of <IShopRepository>(), Mock.Of <IUserRepository>()); ServiceActionResult result = service.AssignUserToShop(Guid.Empty, Guid.Parse("5d3e3599-5e38-44e7-a0d9-84abef706163")); result.Status.Should().Be(ActionStatus.NotSuccessfull); }
public void WhenLoginIsNullOrEmptyThenReturnNotSuccessfull(string userLogin) { var service = new UserAssignmentService(Mock.Of <IShopRepository>(), Mock.Of <IUserRepository>()); ServiceActionResult result = service.AssignUserToShop(Guid.Empty, Guid.Empty); result.Status.Should().Be(ActionStatus.NotSuccessfull); }
public void WhenProductCategoryIsNullThenNotSuccessfullStatusIsReturned() { ProductCategoryService service = new ProductCategoryService(Mock.Of <IProductCategoryRepository>(), Mock.Of <IShopRepository>()); ServiceActionResult result = service.AddProductCategory(null); result.Status.Should().Be(ActionStatus.NotSuccessfull); result.Reason.Should().Be("Product category cannot be null"); }
public ActionResult RemoveCategory(Guid productCategoryGuid) { if (!ModelState.IsValid) { return(RedirectToMainView()); } ServiceActionResult result = _productCategoryService.RemoveProductCategory(productCategoryGuid); return(RedirectToMainView()); }
public ActionResult UnassignShopFromUser(Guid userGuid, Guid shopGuid) { ServiceActionResult result = _userAssignmentService.UnassignUserFromShop(userGuid, shopGuid); if (result.Status != ActionStatus.Successfull) { return(View("UnexpectedError", result)); } return(RedirectToAction("AssignShop", new { userGuid })); }
public void WhenExceptionHappenedThenReturnWithExceptionActionResult() { var shopRepository = Mock.Of <IShopRepository>(); Mock.Get(shopRepository).Setup(r => r.GetShopById(Guid.Parse("5d3e3599-5e38-44e7-a0d9-84abef706163"))).Throws <Exception>(); var service = new UserAssignmentService(shopRepository, Mock.Of <IUserRepository>(r => r.GetUserByLogin("testLogin") == new User("testLogin", "testPassword", UserRank.Client))); ServiceActionResult result = service.AssignUserToShop(Guid.Empty, Guid.Parse("5d3e3599-5e38-44e7-a0d9-84abef706163")); result.Status.Should().Be(ActionStatus.WithException); }
private IActionResult GetActionResult(ServiceActionResult result) { if (result.Succeeded) { return(Ok(new { })); } else { return(BadRequest(new { message = result.GetErrorsMessage() })); } }
public void exec_ServiceFunctionWithoutParameter() { // Arrange TestCaseTesterController controller = new TestCaseTesterController(); // Act ServiceActionResult res = controller.Exec("ServiceFunctionWithoutParameter", null); // Assert Assert.AreEqual("OK!", res.errorMessage); }
private ActionResult ShopActivation(Guid shopGuid, bool isShopActive) { ServiceActionResult activationResult = _shopConfigurationClient.ShopActivation(shopGuid, isActive: isShopActive); if (activationResult.Status != ActionStatus.Successfull) { ViewBag.Error = activationResult.Reason; } return(RedirectToAction("AdminShopList", "Shop")); }
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 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 WhenShopGuidIsEmptyGuidThenNotSuccessfullActionIsReturned() { ProductCategoryService service = new ProductCategoryService(Mock.Of <IProductCategoryRepository>(), Mock.Of <IShopRepository>()); ServiceActionResult result = service.AddProductCategory(new ProductCategoryDto() { CategoryName = "testName", ShopGuid = Guid.Empty }); result.Status.Should().Be(ActionStatus.NotSuccessfull); result.Reason.Should().Be("Shop guid cannot be empty"); }
public void WhenUserAndShopExistThenReturnSuccessActionResult() { var userToAssign = new User("testLogin", "testPassword", UserRank.Client); var shop = new Shop(); var shopRepository = Mock.Of <IShopRepository>(r => r.GetShopById(Guid.Parse("5d3e3599-5e38-44e7-a0d9-84abef706163")) == shop); var service = new UserAssignmentService(shopRepository, Mock.Of <IUserRepository>(r => r.GetUserByLogin("testLogin") == userToAssign)); ServiceActionResult result = service.AssignUserToShop(Guid.Empty, Guid.Parse("5d3e3599-5e38-44e7-a0d9-84abef706163")); result.Status.Should().Be(ActionStatus.Successfull); Mock.Get(shopRepository).Verify(r => r.AssignUser(shop, userToAssign), Times.Once); }
public void Get() { // Arrange TestCaseTesterController controller = new TestCaseTesterController(); // Act ServiceActionResult res = controller.Get(null); // Assert Assert.IsNotNull(res.data); Assert.IsNull(res.errorMessage); }
public void GetById() { // Arrange TestCaseTesterController controller = new TestCaseTesterController(); // Act ServiceActionResult res = controller.GetByID("5D4A773E-2FF0-4BC0-8167-A2460135BBBF"); // Assert Assert.IsNotNull(res.data); Assert.IsNull(res.errorMessage); }
public void exec() { // Arrange UserController controller = new UserController(); FWPostBody body = new FWPostBody("testpatient"); // Act ServiceActionResult res = controller.Exec("ValidateUserNameForInsert", body); // Assert Assert.IsNotNull(res.errorMessage); }
public void GetById() { // Arrange UserController controller = new UserController(); // Act ServiceActionResult res = controller.GetByID("1"); // Assert Assert.IsNotNull(res.data); Assert.IsNull(res.errorMessage); }
public void WhenProductCategoryNameIsNullOrEmptyThenNotSuccessfullStatusIsReturned(string categoryName) { ProductCategoryService service = new ProductCategoryService(Mock.Of <IProductCategoryRepository>(), Mock.Of <IShopRepository>()); ServiceActionResult result = service.AddProductCategory(new ProductCategoryDto() { CategoryName = categoryName }); result.Status.Should().Be(ActionStatus.NotSuccessfull); result.Reason.Should().Be("Category name cannot be null or empty"); }
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 exec_ServiceFunctionWithOneParameterRetValue() { // Arrange TestCaseTesterController controller = new TestCaseTesterController(); FWPostBody body = new FWPostBody("paramValue"); // Act ServiceActionResult res = controller.Exec("ServiceFunctionWithOneParameterRetValue", body); // Assert Assert.AreEqual("OK! paramValue", res.data); }
public ActionResult RemoveProduct(Guid productGuid) { ServiceActionResult result = _productAdministrationService.RemoveProduct(productGuid); if (result.Status == ActionStatus.Successfull) { return(RedirectToAction("AdminShopProduct", "ShopAdministrationCore")); } ViewBag.ErrorMessage = result.Reason; return(View("NotRemovedProduct")); }
public void GetErrorsMessage_ReturnsEmpty_WhenNoError() { //ARRANGE var actionResult = new ServiceActionResult() { Succeeded = false }; //ACT var result1 = actionResult.GetErrorsMessage(); //ASSERT Assert.Equal(string.Empty, result1); }
public ActionResult EditProduct(AddProductViewModel productViewModel) { if (!ModelState.IsValid) { return(AddProduct()); } ServiceActionResult result = _productAdministrationService.EditProduct(productViewModel.ProductView.Map()); if (result.Status == ActionStatus.Successfull) { return(RedirectToAction("AdminShopProduct", "ShopAdministrationCore")); } return(AddProduct()); }
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); }