public void UserSharedFileCollectionViewModel_ProcessSelectedFileTest_AddAsNewFile() { var mockFileUploadService = new Mock <IFileUploadService>(); mockFileUploadService .Setup(uploader => uploader.ShowFileReplacementPrompt( It.IsAny <IEnumerable <SharedFileViewModel> >(), It.IsAny <SharedFileViewModel>(), It.IsAny <OperationCallback <SharedFileReplaceCommands> >())) .Callback((IEnumerable <SharedFileViewModel> sharedFileViewModels, SharedFileViewModel sharedFileViewModel, OperationCallback <SharedFileReplaceCommands> callback) => { sharedFileViewModel.Model.OriginalFileName += "_copy"; callback(null, SharedFileReplaceCommands.SaveAs); }); var sampleVm = new SampleUserSharedFileCollectionViewModel(); sampleVm.FileUploadService = mockFileUploadService.Object; int initialCount = sampleVm.ViewModels.Count; var oldSharedFileVm = sampleVm.ViewModels.First(); var sharedFile = new SharedFile() { SharedFileId = Guid.NewGuid(), OriginalFileName = oldSharedFileVm.Model.OriginalFileName }; var newSharedFileVm = viewModelFactory.GetViewModel <SharedFileViewModel>(vm => vm.Model.SharedFileId == sharedFile.SharedFileId); newSharedFileVm.Model = sharedFile; sampleVm.ProcessSelectedFile(newSharedFileVm); Assert.AreEqual(initialCount + 1, sampleVm.ViewModels.Count); Assert.IsTrue(sampleVm.ViewModels.Contains(newSharedFileVm)); Assert.IsTrue(sampleVm.ViewModels.Contains(oldSharedFileVm)); }
public void UserSharedFileCollectionViewModel_ProcessSelectedFileTest_AddNewFile() { var sampleVm = new SampleUserSharedFileCollectionViewModel(); int initialCount = sampleVm.ViewModels.Count; var sharedFile = new SharedFile() { SharedFileId = Guid.NewGuid(), OriginalFileName = Guid.NewGuid().ToString() }; var sharedFileVm = viewModelFactory.GetViewModel <SharedFileViewModel>(vm => vm.Model.SharedFileId == sharedFile.SharedFileId); sharedFileVm.Model = sharedFile; sampleVm.ProcessSelectedFile(sharedFileVm); Assert.AreEqual(initialCount + 1, sampleVm.ViewModels.Count); Assert.IsTrue(sampleVm.ViewModels.Contains(sharedFileVm)); }