public async Task VerifyOkButtonWorks() { var vm = new FileRevisionDialogViewModel(this.fileRevision, this.thingTransaction, this.session.Object, false, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.file); Assert.IsFalse(vm.OkCanExecute); vm.Name = "Name"; Assert.IsFalse(vm.OkCanExecute); var fileType = new FileType(Guid.NewGuid(), null, null); vm.FileType.Add(fileType); Assert.IsFalse(vm.OkCanExecute); vm.LocalPath = "c:\\somewhere\\somefile.txt"; Assert.IsFalse(vm.OkCanExecute); vm.ContentHash = "DOESNOTMATTER"; Assert.IsTrue(vm.OkCanExecute); Assert.AreEqual(null, this.fileRevision.LocalPath); Assert.AreEqual(null, this.fileRevision.ContentHash); //No root vm.OkCommand.Execute(null); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>(), It.IsAny <IEnumerable <string> >()), Times.Never); Assert.IsNull(vm.WriteException); Assert.IsTrue(vm.DialogResult.Value); Assert.AreEqual(vm.LocalPath, this.fileRevision.LocalPath); Assert.AreEqual(vm.ContentHash, this.fileRevision.ContentHash); }
public void VerifyThatUpdatePropertiesWork() { this.file.FileRevision.Clear(); var vm = new FileRevisionDialogViewModel(this.fileRevision, this.thingTransaction, this.session.Object, false, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.file); Assert.IsNotNull(vm.CreatedOn); Assert.AreEqual(this.participant, vm.SelectedCreator); Assert.IsNull(vm.LocalPath); Assert.IsNull(vm.SelectedContainingFolder); Assert.AreEqual(0, vm.FileType.Count); this.file.CurrentContainingFolder = new Folder(); this.file.FileRevision.Add(this.fileRevision); this.fileRevision.LocalPath = "c:\\somewhere\\somefile.txt"; this.fileRevision.FileType.Add(this.fileType1); this.fileRevision.FileType.Add(this.fileType2); var vm2 = new FileRevisionDialogViewModel(this.fileRevision, this.thingTransaction, this.session.Object, false, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.file); Assert.IsNotNull(vm2.CreatedOn); Assert.AreEqual(this.participant, vm2.SelectedCreator); Assert.AreEqual(this.fileRevision.LocalPath, vm2.LocalPath); Assert.AreEqual(this.file.CurrentContainingFolder, vm2.SelectedContainingFolder); Assert.AreEqual(2, vm2.FileType.Count); }
public void VerifyUpdateDoesIsNotAllowed() { Assert.Throws <InvalidOperationException>(() => { var vm = new FileRevisionDialogViewModel(this.fileRevision, this.thingTransaction, this.session.Object, false, ThingDialogKind.Update, this.thingDialogNavigationService.Object, this.store); }); }
public void VerifyThatPopulateFileTypeWorks() { this.fileRevision.FileType.Add(this.fileType1); this.fileRevision.FileType.Add(this.fileType2); this.fileRevision.FileType.Move(0, 1); var vm = new FileRevisionDialogViewModel(this.fileRevision, this.thingTransaction, this.session.Object, false, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.file); Assert.AreEqual(2, vm.FileType.Count); Assert.AreEqual(this.fileType1, vm.FileType.Last()); Assert.AreEqual(this.fileType2, vm.FileType.First()); }
public async Task VerifyDownloadFile() { var vm = new FileRevisionDialogViewModel(this.fileRevision, this.thingTransaction, this.session.Object, false, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.file); Assert.IsFalse(vm.CanDownloadFile); vm = new FileRevisionDialogViewModel(this.fileRevision, this.thingTransaction, this.session.Object, false, ThingDialogKind.Inspect, this.thingDialogNavigationService.Object, this.file); Assert.IsTrue(vm.CanDownloadFile); vm.DownloadFileCommand.Execute(null); this.downloadFileService.Verify(x => x.ExecuteDownloadFile(vm, vm.Thing), Times.Once); }
public void VerifyAddFileType() { var vm = new FileRevisionDialogViewModel(this.fileRevision, this.thingTransaction, this.session.Object, false, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.file); CollectionAssert.IsEmpty(vm.FileType); vm.AddFileTypeCommand.Execute(null); CollectionAssert.IsNotEmpty(vm.FileType); Assert.AreEqual(1, vm.FileType.Count); // Try to add the same one vm.AddFileTypeCommand.Execute(null); Assert.AreEqual(1, vm.FileType.Count); }
public async Task VerifyAddFile() { var path = "c:\\folder\\file.jpg.zip"; this.fileDialogService.Setup(x => x.GetOpenFileDialog(It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>())).Returns(new string[] { path }); var vm = new FileRevisionDialogViewModel(this.fileRevision, this.thingTransaction, this.session.Object, true, ThingDialogKind.Inspect, this.thingDialogNavigationService.Object, this.file); Assert.IsTrue(vm.CanDownloadFile); vm.AddFileCommand.Execute(null); this.fileDialogService.Verify(x => x.GetOpenFileDialog(It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>())); Assert.AreEqual(path, vm.LocalPath); Assert.AreEqual("file", vm.Name); CollectionAssert.AreEqual(new[] { this.fileType1, this.fileType2 }, vm.FileType); }
public void VerifyDeleteFileType() { var vm = new FileRevisionDialogViewModel(this.fileRevision, this.thingTransaction, this.session.Object, false, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.file); CollectionAssert.IsEmpty(vm.FileType); Assert.IsFalse(vm.CanDeleteFileType); vm.FileType.Add(new FileType()); CollectionAssert.IsNotEmpty(vm.FileType); Assert.IsFalse(vm.CanDeleteFileType); vm.SelectedFileType = vm.FileType.First(); Assert.IsTrue(vm.CanDeleteFileType); vm.DeleteFileTypeCommand.Execute(null); CollectionAssert.IsEmpty(vm.FileType); }
public void VerifyMoveUpFileType() { var vm = new FileRevisionDialogViewModel(this.fileRevision, this.thingTransaction, this.session.Object, false, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.file); Assert.IsFalse(vm.CanMoveUpFileType); vm.FileType.Add(new FileType()); Assert.IsFalse(vm.CanMoveUpFileType); vm.SelectedFileType = vm.FileType.First(); Assert.IsFalse(vm.CanMoveUpFileType); vm.FileType.Add(new FileType()); Assert.IsFalse(vm.CanMoveUpFileType); vm.SelectedFileType = vm.FileType.Last(); Assert.IsTrue(vm.CanMoveUpFileType); vm.MoveUpFileTypeCommand.Execute(null); Assert.AreEqual(vm.SelectedFileType, vm.FileType.First()); }
public void VerifyThatPathCalculationWorks() { var vm = new FileRevisionDialogViewModel(this.fileRevision, this.thingTransaction, this.session.Object, false, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.file); Assert.AreEqual(vm.Path, string.Empty); Assert.AreEqual(vm.Path, string.Empty); vm.Name = "FileName"; Assert.AreEqual(vm.Path, $"{vm.Name}"); var folder = new Folder() { Name = "Folder" }; vm.SelectedContainingFolder = folder; Assert.AreEqual(vm.Path, $"/{vm.SelectedContainingFolder.Name}/{vm.Name}"); vm.FileType.Add(this.fileType1); vm.FileType.Add(this.fileType2); Assert.AreEqual(vm.Path, $"/{vm.SelectedContainingFolder.Name}/{vm.Name}.{vm.FileType.First().Extension}.{vm.FileType.Last().Extension}"); }
public void VerifyThatPopulatePossibleFileTypeWorks() { var vm = new FileRevisionDialogViewModel(this.fileRevision, this.thingTransaction, this.session.Object, false, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.file); Assert.AreEqual(2, vm.PossibleFileType.Count); }