コード例 #1
0
        public async Task Replace_FileNotContained_Added()
        {
            dialogMock.Setup(d => d.OpenMediaFile(It.IsAny <object> ())).Returns(new MediaFile {
                FilePath = "new"
            });

            MediaFileSet   fileSet   = new MediaFileSet();
            MediaFileSetVM fileSetVM = new MediaFileSetVM {
                Model = fileSet
            };

            fileSet.Add(new MediaFile {
                FilePath = "old"
            });

            MediaFileVM newFileVM = await App.Current.EventsBroker.PublishWithReturn <ReplaceMediaFileEvent, MediaFileVM> (new ReplaceMediaFileEvent {
                OldFileSet = fileSetVM,
                OldFile    = new MediaFileVM {
                    Model = new MediaFile {
                        FilePath = "not contained"
                    }
                },
            });

            Assert.IsNotNull(newFileVM);
            Assert.IsNotNull(newFileVM.Model);
            Assert.AreEqual("new", newFileVM.FilePath);
            Assert.AreEqual("new", newFileVM.Model.FilePath);
            Assert.AreEqual(2, fileSetVM.Count());
        }
コード例 #2
0
        public async Task Replace_FileNotSelected_NothingChanged()
        {
            dialogMock.Setup(d => d.OpenMediaFile(It.IsAny <object> ())).Returns <MediaFile> (null);

            MediaFileSet   fileSet   = new MediaFileSet();
            MediaFileSetVM fileSetVM = new MediaFileSetVM {
                Model = fileSet
            };

            fileSet.Add(new MediaFile {
                FilePath = "old"
            });

            MediaFileVM newFileVM = await App.Current.EventsBroker.PublishWithReturn <ReplaceMediaFileEvent, MediaFileVM> (new ReplaceMediaFileEvent {
                OldFileSet = fileSetVM,
                OldFile    = fileSetVM.ViewModels.First(),
            });

            Assert.IsNotNull(newFileVM);
            Assert.IsNotNull(newFileVM.Model);
            Assert.AreSame(fileSetVM.ViewModels.First(), newFileVM);
            Assert.AreEqual(fileSetVM.ViewModels.First().Model, newFileVM.Model);
            Assert.AreEqual(1, fileSetVM.Count());
        }