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); }
public async Task VisibleControllerFilter() { var data = new VisibleApiDataHandler(); var list = new List <VisibleDisplay> { VisibleData.GetFirstDisplay() }; var filter = new VisibleFilter { TenantRestrict = true }; data.Result.Setup(m => m.Execute(It.IsAny <VisibleDisplayByFilter>())).Returns(list); var controller = new VisibleController(data, Cloud, Logic) { CurrentUser = StandardUser }; var result = await controller.Filter(filter) as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); result.Value.Should().NotBeNull(); var check = result.Value as PagedResult <IEnumerable <VisibleDisplay> >; check.Should().NotBeNull(); check.Data.Count().Should().Be(list.Count); Assert.That(check.Data, Is.DeepEqualTo(list)); data.HasExecuted.Should().BeTrue(); data.Result.Verify(s => s.Execute(It.IsAny <VisibleDisplayByFilter>()), Times.Once()); }
public async Task VisibleDisplayByIdDataTest() { using var store = GetDocumentStore(); using var session = store.OpenAsyncSession(); var query = new VisibleDisplayById { Session = session, Id = VisibleData.FirstId }; await query.Execute(); query.Result.Should().NotBeNull(); query.Result.Id.Should().Be(VisibleData.FirstId); Assert.That(query.Result, Is.DeepEqualTo(VisibleData.GetFirstDisplay())); }
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); }
/// <summary> /// This method is used to load the VisibleData collection with the proper set of sequences. /// </summary> public void ReloadSequences() { INotificationVisualizer wait = Resolve <INotificationVisualizer>(); Debug.Assert(wait != null); using (wait.BeginWait("Refreshing View", "Loading Data")) { _groupedList.Clear(); // No entities? if (GroupedEntities == null) { if (_taxonomyJumper != null) { _taxonomyJumper.RaiseCloseRequest(); } VisibleData.Clear(); return; } // Add all the entries var seqCollection = new AlignmentEntityViewModel[GroupedEntities.Count]; Parallel.For(0, GroupedEntities.Count, i => seqCollection[i] = new AlignmentEntityViewModel(this, GroupedEntities[i], i)); // Push it to the UI VisibleData.Clear(); foreach (var item in seqCollection) { VisibleData.Add(item); } // Add in the proper line numbers var sequences = VisibleData.Where(vd => vd.IsSequence).ToList(); Parallel.For(0, sequences.Count, i => { sequences[i].DisplayIndex = i + 1; }); // If the taxonomy view is alive, refresh it. if (_taxonomyJumper != null) { if (IsGrouped) { _taxonomyJumper.ChangedGrouping(_data.Entities, Options.MinGroupingRange); } else { _taxonomyJumper.RaiseCloseRequest(); } } } }
public async Task VisibleDisplayByFilterDataTestImage() { var filter = new VisibleFilter { ImageRestrict = true, Take = 10 }; using var store = GetDocumentStore(); using var session = store.OpenAsyncSession(); var query = new VisibleDisplayByFilter { Session = session, Filter = filter, CurrentUser = StandardUser }; await query.Execute(); query.Result.Should().NotBeNull(); query.Result.Count().Should().Be(1); Assert.That(query.Result.First(), Is.DeepEqualTo(VisibleData.GetFirstDisplay())); }
/// <summary> /// This is invoked when the user selects a "jump" in the taxonomy view /// </summary> /// <param name="e">Name of taxonomy group to jump to</param> private void OnJumpToTaxonomyGroup(TaxonomyJumpEventArgs e) { var groupHeader = VisibleData.FirstOrDefault(vd => vd.IsGroupHeader && vd.Header == e.Name); if (groupHeader != null) { // De-select everything VisibleData.Where(vd => vd.IsSelected).ForEach(vd => vd.IsSelected = false); // Reposition and select this specific grouping TopRow = groupHeader.Position; if (e.SelectRows) { Enumerable.Range(groupHeader.Position + 1, TotalRows - groupHeader.Position - 1).TakeWhile( i => VisibleData[i].IsSequence).Select(i => VisibleData[i]).ForEach(vd => vd.IsSelected = true); } } }
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 VisibleControllerDisplayUnauthorized() { var data = new VisibleApiDataHandler(); var display = VisibleData.GetFirstDisplay(); data.Result.Setup(m => m.Execute(It.IsAny <VisibleDisplayById>())).Returns(display); var controller = new VisibleController(data, Cloud, Logic) { CurrentUser = NonTenantUser }; var result = await controller.Display(VisibleData.FirstId) as UnauthorizedResult; result.Should().NotBeNull(); result.Should().BeOfType <UnauthorizedResult>(); data.HasExecuted.Should().BeTrue(); data.Result.Verify(s => s.Execute(It.IsAny <VisibleDisplayById>()), Times.Once()); }
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); }
void OnSheetLoaded(GstuSpreadSheet ss) { datas = new VisibleData(); for (int i = 1; i < ss.columns["A"].Count; i++) { int id = int.Parse(ss.rows[i + 1][0].value); datas.Add(id, new Data()); for (int j = 0; j < ss.rows[i + 1].Count; j++) { //Debug.Log("ss.rows[i]: " + ss.rows[i + 1][j].value); datas[id].UpdateStats(ss.rows[i + 1]); } } #if UNITY_EDITOR EditorUtility.SetDirty(this); #endif onGoogleSynced?.Invoke(); }
public async Task VisibleControllerDisplay() { var data = new VisibleApiDataHandler(); var display = VisibleData.GetFirstDisplay(); data.Result.Setup(m => m.Execute(It.IsAny <VisibleDisplayById>())).Returns(display); var controller = new VisibleController(data, Cloud, Logic) { CurrentUser = StandardUser }; var result = await controller.Display(VisibleData.FirstId) as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); Assert.That(result.Value, Is.DeepEqualTo(display)); data.HasExecuted.Should().BeTrue(); data.Result.Verify(s => s.Execute(It.IsAny <VisibleDisplayById>()), 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 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()); }
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()); }