public async Task VisibleControllerDeleteFailed() { var data = new VisibleApiDataHandler(); var logic = new CoreApiLogicHandler(); var model = VisibleData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <Loader <VisibleFile> >())).Returns(model); logic.Result.Setup(m => m.Execute(It.IsAny <FileDelete>())) .Returns(ActionConfirm.CreateFailure("It went wrong")); var controller = new VisibleController(data, Cloud, logic) { CurrentUser = StandardUser }; var result = await controller.Delete(VisibleData.FirstId) as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); var check = result.Value as ConfirmViewModel; check.Success.Should().BeFalse(); logic.Result.Verify(s => s.Execute(It.IsAny <FileDelete>()), Times.Once()); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <Loader <VisibleFile> >()), Times.Once); }
public async Task VisibleControllerDeleteUnauthorized() { var data = new VisibleApiDataHandler(); var model = VisibleData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <Loader <VisibleFile> >())).Returns(model); var controller = new VisibleController(data, Cloud, Logic) { CurrentUser = NonTenantUser }; var result = await controller.Delete(VisibleData.FirstId) as UnauthorizedResult; result.Should().NotBeNull(); result.Should().BeOfType <UnauthorizedResult>(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <Loader <VisibleFile> >()), Times.Once); }