public async Task FileDeleteLogicFail() { var data = new FakeApiDataEntityHandler <VisibleFile>(); var logic = new FakeApiLogicHandler(); var cloud = new FakeCloudHandler(); var model = VisibleData.GetFirst(); cloud.Result.Setup(m => m.Execute(It.IsAny <DeleteCmd>())) .Returns(ActionConfirm.CreateFailure(("Delete Failed"))); var command = new FileDelete { DataHandler = data, File = model, CloudHandler = cloud, LogicHandler = logic }; await command.Execute(); cloud.HasExecuted.Should().BeTrue(); data.HasExecuted.Should().BeFalse(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <Delete <VisibleFile> >()), Times.Never()); }
public async Task FileDeleteLogicDoc() { var data = new FakeApiDataEntityHandler <VisibleFile>(); var logic = new FakeApiLogicHandler(); var cloud = new FakeCloudHandler(); var model = VisibleData.GetFirst(); model.IsImage = false; model.IsDocument = true; data.Result.Setup(m => m.Execute(It.IsAny <Delete <VisibleFile> >())).Returns(true); cloud.Result.Setup(m => m.Execute(It.IsAny <DeleteCmd>())) .Returns(ActionConfirm.CreateSuccess("File Loaded")); var command = new FileDelete { DataHandler = data, File = model, CloudHandler = cloud, LogicHandler = logic }; await command.Execute(); cloud.HasExecuted.Should().BeTrue(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <Delete <VisibleFile> >()), Times.Once()); }
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); }
protected override void SetupDatabase(IDocumentStore store) { store.ExecuteIndex(new VisibleIndex()); store.ExecuteIndex(new FavFanIndex()); using (var session = store.OpenSession()) { session.Store(VisibleData.GetFirst()); session.SaveChanges(); } WaitForIndexing(store); }
public void VisibleMasterTest() { var config = new MapperConfiguration(cfg => { cfg.CreateMap <VisibleFile, VisibleMaster>(); cfg.CreateMap <VisibleMaster, VisibleFile>(); }); var mapper = new Mapper(config); var master = mapper.Map <VisibleMaster>(VisibleData.GetFirst()); var document = mapper.Map <VisibleFile>(master); master.Should().NotBeNull(); document.Should().NotBeNull(); document.IsImage.Should().BeTrue(); document.IsVideo.Should().BeFalse(); document.IsDocument.Should().BeFalse(); }
public async Task LoaderControllerUploadSuccess() { var data = new VisibleApiDataHandler(); var logic = new CoreApiLogicHandler(); var model = VisibleData.GetFirst(); logic.Result.Setup(m => m.Execute(It.IsAny <ProcessFile>())).Returns(ActionConfirm.CreateSuccess(model)); var controller = new LoaderController(data, Cloud, logic) { CurrentUser = StandardUser }; var result = await controller.Upload(VisibleData.GetFile()) as JsonResult; result.Should().NotBeNull(); result.Should().BeOfType <JsonResult>(); data.HasExecuted.Should().BeFalse(); logic.HasExecuted.Should().BeTrue(); }
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); }
public async Task ProcessImageLogicExists() { var file = new FakeFile(); var data = new FakeApiDataEntityHandler <ImageFile>(); var logic = new CoreApiLogicHandler(); var cloud = new FakeCloudHandler(); var model = VisibleData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <Loader <ImageFile> >())).Returns(model); data.Result.Setup(m => m.Execute(It.IsAny <Persist <ImageFile> >())).Returns(model); cloud.Result.Setup(m => m.Execute(It.IsAny <UploadCmd>())) .Returns(ActionConfirm.CreateSuccess("File Uploaded")); var command = new ProcessImage { DataHandler = data, Source = file, CloudHandler = cloud, LogicHandler = logic, CurrentUser = StandardUser, Model = model, LoadType = "test", ExistingId = model.Id }; await command.Execute(); cloud.HasExecuted.Should().BeTrue(); cloud.Result.Verify(s => s.Execute(It.IsAny <UploadCmd>()), Times.AtLeastOnce()); command.Result.Success.Should().BeTrue(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <Loader <ImageFile> >()), Times.Once()); data.Result.Verify(s => s.Execute(It.IsAny <Persist <ImageFile> >()), Times.Once()); }
public async Task CheckProfileImageLogicNoImage() { var data = new FakeApiDataEntityHandler<ImageFile>(); var logic = new FakeApiLogicHandler(); var model = VisibleData.GetFirst(); var profile = UserData.GetFifth(); profile.ProfileId = model.Id; data.Result.Setup(m => m.Execute(It.IsAny<Loader<ImageFile>>())).Returns(null); var command = new CheckProfileImage { DataHandler = data, LogicHandler = logic, Model = profile }; await command.Execute(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny<Loader<ImageFile>>()), Times.Once()); }
public async Task ProcessImageLogicMissing() { var file = new FakeFile() { FileName = "xxxMissingxxx" }; var data = new FakeApiDataEntityHandler <ImageFile>(); var logic = new CoreApiLogicHandler(); var cloud = new FakeCloudHandler(); var model = VisibleData.GetFirst(); var command = new ProcessImage { DataHandler = data, Source = file, CloudHandler = cloud, LogicHandler = logic, CurrentUser = StandardUser, Model = model, LoadType = "test" }; await command.Execute(); cloud.HasExecuted.Should().BeFalse(); cloud.Result.Verify(s => s.Execute(It.IsAny <UploadCmd>()), Times.Never()); command.Result.Success.Should().BeFalse(); data.HasExecuted.Should().BeFalse(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <Loader <ImageFile> >()), Times.Never()); data.Result.Verify(s => s.Execute(It.IsAny <Persist <ImageFile> >()), Times.Never()); }