public void DeleteMustReturnBadRequest() { _subscriptionMediator.Setup(m => m.Delete(It.IsAny <Guid>())).Throws(new System.Exception()); var result = target.Delete(Guid.NewGuid()); var requestResult = result as BadRequestObjectResult; Assert.NotNull(requestResult); Assert.Equal(400, requestResult.StatusCode); }
public void Test_DeleteSubscriptionById_IsBeingDeleted() { var subscriptions = _subscriptionController.Get(); var subscription = subscriptions.First(); _subscriptionController.Delete(subscription.Id); subscriptions = _subscriptionController.Get(); Assert.IsFalse(subscriptions.Any(c => c.Id == subscription.Id)); }
public void WhenAUserUnSubscribes(string lastName, string firstName, string email) { var controller = new SubscriptionController(this.dataStorageMock.Object, this.reportingMock.Object) { ControllerContext = MvcMockHelpers.GetControllerContextMock("POST") }; var actionResult = controller.Delete(email, new FormCollection()); ScenarioContext.Current["Controller"] = controller; ScenarioContext.Current["ActionResult"] = actionResult; }
public async void Delete_Errors() { SubscriptionControllerMockFacade mock = new SubscriptionControllerMockFacade(); var mockResult = new Mock <ActionResponse>(); mockResult.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Delete(It.IsAny <string>())).Returns(Task.FromResult <ActionResponse>(mockResult.Object)); SubscriptionController controller = new SubscriptionController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); IActionResult response = await controller.Delete(default(string)); response.Should().BeOfType <ObjectResult>(); (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); mock.ServiceMock.Verify(x => x.Delete(It.IsAny <string>())); }