public void AddToCancellationQueue_Given_BillingCanelQueue_Is_Not_Populated_Expect_SuccesMessage() { //Arrange var kernel = new MoqMockingKernel(); var workflowStorageComponent = kernel.GetMock <IWorkflowStorageComponent>(); int orderItemId = 666; int providerId = 1; workflowStorageComponent.Setup(p => p.PopulateBillingCancelQueue(It.IsAny <BillingExtractState>())) .Callback((BillingExtractState state) => { Assert.AreEqual(666, state.OrderItemId); Assert.AreEqual(providerId, state.ProviderId); Assert.AreEqual((int)Activation.Cancelled, state.ExtractStatus); }) .Returns(false); ComponentOrderCancellation componentOrderAddToCancelQueue = new ComponentOrderCancellation(kernel); //Act var response = componentOrderAddToCancelQueue.AddToCancellationQueue(orderItemId, providerId); //Assert Assert.AreEqual("Error occured while populating queue", response.Message); Assert.IsFalse(response.IsSuccess); workflowStorageComponent.VerifyAll(); }
public void AddToCancellationQueue_Given_NoProvidersExist_Expect_ExceptionMessage() { var kernel = new MoqMockingKernel(); var workflowStorageComponent = kernel.GetMock <IWorkflowStorageComponent>(); var providerMock = kernel.GetMock <IRepositoryProvider>(); int orderItemId = 666; int providerId = 1; workflowStorageComponent.Setup(p => p.PopulateBillingCancelQueue(It.IsAny <BillingExtractState>())) .Throws <Exception>(); ComponentOrderCancellation componentOrderAddToCancelQueue = new ComponentOrderCancellation(kernel); //Act var response = componentOrderAddToCancelQueue.AddToCancellationQueue(orderItemId, providerId); //Assert Assert.AreEqual("Exception: Adding Cancellation to Billing Cancel Queue", response.Message); Assert.IsFalse(response.IsSuccess); workflowStorageComponent.VerifyAll(); providerMock.Verify(p => p.GetNameByProviderId(providerId), Times.Once); }