public void SimfyActivation_Given_IsOrderItemActivated_Expect_ValidationMessage() { //Arrange var kernel = new MoqMockingKernel(); var thirdPartyService = kernel.GetMock <IThirdPartyServiceSimfy>(); var orderItemRepo = kernel.GetMock <IRepositoryOrderItemData>(); orderItemRepo.Setup(p => p.IsOrderItemActivated(1)).Returns(true); orderItemRepo.Setup(p => p.GetByOrderItemId(1)) .Returns(new EnumerableQuery <OrderItemData>(new List <OrderItemData>() { new OrderItemData() { IsActivated = true } })); ComponentSimfy componentSimfy = new ComponentSimfy(kernel); //Act var response = componentSimfy.SimfyActivation("password", "password", 1); //Assert Assert.AreEqual("Order is Activated", response.Message); Assert.IsTrue(response.IsSuccess); orderItemRepo.Verify(p => p.GetByOrderItemId(1), Times.Once); orderItemRepo.Verify(p => p.IsOrderItemActivated(1), Times.Never); }
public void SimfyActivation_Given_EmptyPassword_Expect_ValidationMessage() { //Arrange var kernel = new MoqMockingKernel(); ComponentSimfy componentSimfy = new ComponentSimfy(kernel); //Act var response = componentSimfy.SimfyActivation("password", "", 1); //Assert Assert.AreEqual("Username and Password must be populated.", response.Message); Assert.IsFalse(response.IsSuccess); }
public void SimfyActivation_Given_NoOrderItemInRepo_Expect_ValidationMessage() { //Arrange var kernel = new MoqMockingKernel(); var thirdPartyService = kernel.GetMock <IThirdPartyServiceSimfy>(); var orderItemRepo = kernel.GetMock <IRepositoryOrderItemData>(); orderItemRepo.Setup(p => p.IsOrderItemActivated(1)) .Returns(true); ComponentSimfy componentSimfy = new ComponentSimfy(kernel); //Act var response = componentSimfy.SimfyActivation("password", "password", 1); //Assert Assert.AreEqual("No Order Item Data could be found.", response.Message); Assert.IsFalse(response.IsSuccess); orderItemRepo.Verify(p => p.IsOrderItemActivated(1), Times.Never); }
public void SimfyActivation_Given_ExistingUser_Expect_UserIdReturned() { //Arrange var kernel = new MoqMockingKernel(); var thirdPartyService = kernel.GetMock <IThirdPartyServiceSimfy>(); var orderItemRepo = kernel.GetMock <IRepositoryOrderItemData>(); orderItemRepo.Setup(p => p.IsOrderItemActivated(1)).Returns(true); orderItemRepo.Setup(p => p.GetByOrderItemId(1)) .Returns(new EnumerableQuery <OrderItemData>(new List <OrderItemData>() { new OrderItemData() { IsActivated = false, AccountNumber = "111" } })); ComponentSimfy componentSimfy = new ComponentSimfy(kernel); //Act var response = componentSimfy.SimfyActivation("password", "password", 1); //Assert var realResponse = response as APIItemResponseModel <SimfyAccountCreationResponse>; Assert.IsNotNull(response); Assert.IsTrue(string.IsNullOrEmpty(realResponse.Message)); Assert.IsTrue(realResponse.IsSuccess); var logIn = realResponse.Item.login; Assert.AreEqual("password", logIn); var accountNumber = realResponse.Item.id; Assert.AreEqual("111", accountNumber); orderItemRepo.Verify(p => p.GetByOrderItemId(1), Times.Exactly(1)); orderItemRepo.Verify(p => p.IsOrderItemActivated(1), Times.Never); }
public void SimfyActivation_Given_UserHasEmptyAccountNumber_Expect_serviceAccount_Creation() { //Arrange var kernel = new MoqMockingKernel(); var thirdPartyService = kernel.GetMock <IThirdPartyServiceSimfy>(); var orderItemRepo = kernel.GetMock <IRepositoryOrderItemData>(); var repositoryOrderItem = kernel.GetMock <IRepositoryOrderItem>(); var repositoryDeal = kernel.GetMock <IRepositoryDeal>(); var componentOrderItemData = kernel.GetMock <IRepositoryOrderItemData>(); orderItemRepo.Setup(p => p.IsOrderItemActivated(1)).Returns(true); repositoryOrderItem.Setup(p => p.GetContactByOrderItemId(1, (int)CustomerContactType.MobileNumber)).Returns("0721234567"); repositoryOrderItem.Setup(p => p.GetDealExternalRefByOrderItemId(1)).Returns("0721234567"); repositoryDeal.Setup(p => p.GetByIdAsNoTracking(2)).Returns(new EnumerableQuery <Deal>(new List <Deal>())); orderItemRepo.Setup(p => p.GetByOrderItemId(1)).Returns(new EnumerableQuery <OrderItemData>(new List <OrderItemData>() { new OrderItemData() { IsActivated = false, AccountNumber = "" } })); componentOrderItemData.Setup(p => p.UpdateAccountNumber(1, "1")); APIItemResponseModel <SimfyAccountCreationResponse> serviceReturnResponse = new APIItemResponseModel <SimfyAccountCreationResponse>() { IsSuccess = true, Item = new SimfyAccountCreationResponse() { ResultantUserUUID = "1" } }; thirdPartyService.Setup(p => p.AccountCreation(It.IsAny <SimfyAccountCreateRequest>())) .Callback((SimfyAccountCreateRequest request) => { Assert.AreEqual("password", request.Username); Assert.AreEqual("password", request.Password); Assert.IsFalse(request.ReceiveNewsletter); Assert.IsTrue(request.AcceptPrivacyPolicyAndTermsOfUse); Assert.AreEqual("password", request.Email); Assert.AreEqual("0721234567", request.MobileNumber); Assert.AreEqual("0721234567", request.ExternalReference); }) .Returns(serviceReturnResponse); ComponentSimfy componentSimfy = new ComponentSimfy(kernel); //Act var response = componentSimfy.SimfyActivation("password", "password", 1); //Assert var realResponse = response as APIItemResponseModel <SimfyAccountCreationResponse>; Assert.IsNotNull(response); Assert.IsTrue(string.IsNullOrEmpty(realResponse.Message)); Assert.IsTrue(realResponse.IsSuccess); Assert.IsTrue(ReferenceEquals(serviceReturnResponse, response)); orderItemRepo.Verify(p => p.GetByOrderItemId(1), Times.Exactly(1)); orderItemRepo.Verify(p => p.IsOrderItemActivated(1), Times.Never); repositoryOrderItem.Verify(p => p.GetContactByOrderItemId(1, (int)CustomerContactType.MobileNumber), Times.Once); repositoryOrderItem.Verify(p => p.GetDealExternalRefByOrderItemId(1), Times.Once); componentOrderItemData.VerifyAll(); thirdPartyService.VerifyAll(); }