예제 #1
0
        public void SimfyCancellation_Given_ServiceCancellsSuccesfully_Expect_SuccesMessage()
        {
            //Arrange
            var kernel            = new MoqMockingKernel();
            var thirdPartyService = kernel.GetMock <IThirdPartyServiceSimfy>();
            var orderItemRepo     = kernel.GetMock <IRepositoryOrderItemData>();

            orderItemRepo.Setup(p => p.GetByOrderItemId(1))
            .Returns(new EnumerableQuery <OrderItemData>(new List <OrderItemData>()
            {
                new OrderItemData()
                {
                    AccountNumber = "TestAccouint"
                }
            }));
            thirdPartyService.Setup(p => p.AccountCancellation(It.IsAny <SimfyAccountCancellationRequest>()))
            .Returns(new APIResponseModel()
            {
                IsSuccess = true
            });

            ComponentSimfy componentSimfy = new ComponentSimfy(kernel);
            //Act
            var response = componentSimfy.SimfyCancellation(1);

            //Assert
            Assert.AreEqual("Order cancelled successfully.", response.Message);
            Assert.IsTrue(response.IsSuccess);
            thirdPartyService.VerifyAll();
            orderItemRepo.VerifyAll();
        }
예제 #2
0
        public void SimfyCancellation_Given_ThrowsException_Expect_ExceptionMessage()
        {
            //Arrange
            var kernel            = new MoqMockingKernel();
            var thirdPartyService = kernel.GetMock <IThirdPartyServiceSimfy>();
            var orderItemRepo     = kernel.GetMock <IRepositoryOrderItemData>();

            orderItemRepo.Setup(p => p.GetByOrderItemId(1))
            .Returns(new EnumerableQuery <OrderItemData>(new List <OrderItemData>()
            {
                new OrderItemData()
                {
                    AccountNumber = "TestAccouint"
                }
            }));
            thirdPartyService.Setup(p => p.AccountCancellation(It.IsAny <SimfyAccountCancellationRequest>()))
            .Throws(new System.Exception());

            ComponentSimfy componentSimfy = new ComponentSimfy(kernel);
            //Act
            var response = componentSimfy.SimfyCancellation(1);

            //Assert
            Assert.AreEqual("Exception: Cancelling on Simfy ThirdParty API.", response.Message);
            Assert.IsFalse(response.IsSuccess);
            thirdPartyService.VerifyAll();
            orderItemRepo.VerifyAll();
        }
예제 #3
0
        public void SimfyCancellation_Given_OrderItemIsNull_Expect_ValidationMessage()
        {
            //Arrange
            var kernel            = new MoqMockingKernel();
            var thirdPartyService = kernel.GetMock <IThirdPartyServiceSimfy>();
            var orderItemRepo     = kernel.GetMock <IRepositoryOrderItemData>();

            orderItemRepo.Setup(p => p.GetByOrderItemId(1))
            .Returns(new EnumerableQuery <OrderItemData>(new List <OrderItemData>()));
            ComponentSimfy componentSimfy = new ComponentSimfy(kernel);
            //Act
            var response = componentSimfy.SimfyCancellation(1);

            //Assert
            Assert.AreEqual("Order item data not found.", response.Message);
            Assert.IsFalse(response.IsSuccess);
            orderItemRepo.VerifyAll();
        }