public void Open_WhenUserCancelsFirstDialog_Returns_Test()
        {
            var conductor = new ShellViewModelTestConductor();

            conductor.DialogManager.SetupOpenFileToReturn(x => x.Title == "Open Genome A", null);

            conductor.Shell.Open();

            conductor.DialogManager.AssertOpenFileInvoked(x => x.Title == "Open Genome B", Times.Never());
        }
        public void Open_InvokesOpenFileForFirstDataset_Test()
        {
            var conductor = new ShellViewModelTestConductor();

            conductor.Shell.Open();

            conductor.DialogManager.AssertOpenFileInvoked(x =>
                                                          x.Title == "Open Genome A" &&
                                                          x.DefaultExt == ".txt" &&
                                                          x.Filter == "Text documents (.txt)|*.txt");
        }
        public void Open_WhenLoadingDatasetThrows_UpdatesNotBusy_Test()
        {
            var conductor = new ShellViewModelTestConductor();

            conductor.DialogManager.SetupOpenFileToReturn(x => x.Title == "Open Genome A", "a.txt");
            conductor.Loader.SetupLoadAsyncToThrow <FileNotFoundException>();

            conductor.Shell.Open();

            Assert.False(conductor.Shell.IsBusy);
        }
        public void Open_WhenUserCancelsSecondDialog_LoadsFirstDataset_Test()
        {
            var conductor = new ShellViewModelTestConductor();

            conductor.DialogManager.SetupOpenFileToReturn(x => x.Title == "Open Genome A", "a.txt");
            conductor.DialogManager.SetupOpenFileToReturn(x => x.Title == "Open Genome B", null);
            conductor.Loader.SetupLoadAsyncToReturn(x => x == "a.txt", TestGenomeModel.Create());

            conductor.Shell.Open();

            conductor.Loader.AssertLoadAsyncInvoked(Times.Once());
            conductor.Loader.AssertLoadAsyncInvoked(x => x == "a.txt", Times.Once());
        }
        public void Open_WhenUserCancelsSecondDialog_ActivatesComparison_Test()
        {
            var conductor = new ShellViewModelTestConductor();

            conductor.DialogManager.SetupOpenFileToReturn(x => x.Title == "Open Genome A", "a.txt");
            conductor.DialogManager.SetupOpenFileToReturn(x => x.Title == "Open Genome B", null);
            conductor.Loader.SetupLoadAsyncToReturn(x => x == "a.txt", TestGenomeModel.Create());

            conductor.Shell.Open();

            var comparison = Assert.IsType <ComparisonViewModel>(conductor.Shell.ActiveItem);

            Assert.True(comparison.Snp.All(x => x.GenotypeB == null));
        }
        public void Open_WhenUserSelectsFirstDataset_InvokesOpenFileForSecondDataset_Test()
        {
            var conductor = new ShellViewModelTestConductor();

            conductor.DialogManager.SetupOpenFileToReturn(x => x.Title == "Open Genome A", "a.txt");
            conductor.Loader.SetupLoadAsyncToReturn(x => x == "a.txt", TestGenomeModel.Create());
            conductor.Loader.SetupLoadAsyncToReturn(x => x == "b.txt", TestGenomeModel.Create());

            conductor.Shell.Open();

            conductor.DialogManager.AssertOpenFileInvoked(x =>
                                                          x.Title == "Open Genome B" &&
                                                          x.DefaultExt == ".txt" &&
                                                          x.Filter == "Text documents (.txt)|*.txt");
        }
        public void Open_WhenUserSelectsBothDatasets_LoadsFirstAndSecondDatasets_Test()
        {
            var conductor = new ShellViewModelTestConductor();

            conductor.DialogManager.SetupOpenFileToReturn(x => x.Title == "Open Genome A", "a.txt");
            conductor.DialogManager.SetupOpenFileToReturn(x => x.Title == "Open Genome B", "b.txt");
            conductor.Loader.SetupLoadAsyncToReturn(x => x == "a.txt", TestGenomeModel.Create());
            conductor.Loader.SetupLoadAsyncToReturn(x => x == "b.txt", TestGenomeModel.Create());

            conductor.Shell.Open();

            conductor.Loader.AssertLoadAsyncInvoked(Times.Exactly(2));
            conductor.Loader.AssertLoadAsyncInvoked(x => x == "a.txt", Times.Once());
            conductor.Loader.AssertLoadAsyncInvoked(x => x == "b.txt", Times.Once());
        }
        public void Open_WhenLoadingDatasets_NotifiesOfPropertyChanged_Test()
        {
            var conductor = new ShellViewModelTestConductor();

            conductor.DialogManager.SetupOpenFileToReturn(x => x.Title == "Open Genome A", "a.txt");
            conductor.Loader.SetupLoadAsyncToReturn(x => x == "a.txt", TestGenomeModel.Create());

            conductor.Shell.CreatePropertyChangedObserver()
            .ExpectPropertyChanged(x => x.IsBusy)
            .ExpectPropertyChanged(x => x.ActiveItem)                // null.
            .ExpectPropertyChanged(x => x.ActiveItem)
            .ExpectPropertyChanged(x => x.IsBusy)
            .Verify(x => x.Open());

            Assert.False(conductor.Shell.IsBusy);
        }
        public void Ctor_CorrectlyInitializesMembers_Test()
        {
            var actual = new ShellViewModelTestConductor().Shell;

            Assert.Equal("MG.GCompare", actual.DisplayName);
        }