public void TryToAddMoreThanThreeElementsToFilterTest()
        {
            var projectNotesService = new ProjectNotesServiceMock(5);
            var target  = new OverviewWindowViewModel_Accessor(projectNotesService);
            var filter1 = new MetadataMock(new MetadataTypeMock {
                Name = "Sector"
            }, "Kriterium 1");
            var filter2 = new MetadataMock(new MetadataTypeMock {
                Name = "Sector"
            }, "Kriterium 2");
            var filter3 = new MetadataMock(new MetadataTypeMock {
                Name = "Sector"
            }, "Kriterium 3");
            var filter4 = new MetadataMock(new MetadataTypeMock {
                Name = "Sector"
            }, "Kriterium 4");

            Assert.AreEqual(0, target.Filters.Cast <IMetadata>().Count());
            target.AddFilter(filter1);
            target.AddFilter(filter2);
            target.AddFilter(filter3);
            Assert.AreEqual(3, target.Filters.Cast <IMetadata>().Count());
            target.AddFilter(filter4);
            Assert.AreEqual(3, target.Filters.Cast <IMetadata>().Count());
            Assert.AreEqual(filter1, target.Filters.Cast <IMetadata>().ElementAt(0));
            Assert.AreEqual(filter2, target.Filters.Cast <IMetadata>().ElementAt(1));
            Assert.AreEqual(filter3, target.Filters.Cast <IMetadata>().ElementAt(2));
        }
        public void OnCurrentMainCriteriaChangedTest()
        {
            var projectNotesService = new ProjectNotesServiceMock(1);
            var metadataTypeSector  = new MetadataTypeMock {
                Name = "Sektor"
            };
            var metadataTypeCustomer = new MetadataTypeMock {
                Name = ""
            };
            var metadataSector = new MetadataMock {
                Description = "Sektorkriterium"
            };
            var metadataCustomer = new MetadataMock {
                Description = "Kundenkriterium"
            };

            projectNotesService.Metadata = new Dictionary <IMetadataType, ICollection <IMetadata> >
            {
                { metadataTypeSector, new List <IMetadata> {
                      metadataSector
                  } },
                { metadataTypeCustomer, new List <IMetadata> {
                      metadataCustomer
                  } }
            };

            var target = new OverviewWindowViewModel_Accessor(projectNotesService);

            target.ShowSubcriteriaCommand.Execute(metadataTypeCustomer);

            var c = target.Maincriteria.Cast <IMetadataType>().ElementAt(0);

            target.OnCurrentMainCriteriaChanged(c);
            Assert.AreEqual(target.Subcriteria.Cast <IMetadata>().ElementAt(0).Description, metadataSector.Description);
        }
        public void HideDetailsCommandTest()
        {
            IProjectNotesService             projectNotesService = new ProjectNotesServiceMock(2);
            OverviewWindowViewModel_Accessor target = new OverviewWindowViewModel_Accessor(projectNotesService);

            target.HideDetailsCommand.Execute(null);
            Assert.IsFalse(target.IsDetailViewVisible);
        }
        public void OnShowFilterTest()
        {
            var projectNotesService = new ProjectNotesServiceMock(5);
            var target = new OverviewWindowViewModel_Accessor(projectNotesService);

            Assert.AreEqual(target.IsFilterViewVisible, false);
            target.OnShowFilter(new object());
            Assert.AreEqual(target.IsFilterViewVisible, true);
        }
        public void OnCurrentMainCriteriaChangedTest()
        {
            IProjectNotesService             projectNotesService = new ProjectNotesServiceMock(1);
            OverviewWindowViewModel_Accessor target = new OverviewWindowViewModel_Accessor(projectNotesService);

            Assert.IsNull(target.Subcriteria);
            target.OnCurrentMainCriteriaChanged(new object(), null);
            Assert.IsNotNull(target.Subcriteria);
        }
Beispiel #6
0
        public void OnShowFilterTest()
        {
            var projectNotesService = new ProjectNotesServiceMock(5);
            var target = new OverviewWindowViewModel_Accessor(projectNotesService, null);

            Assert.IsFalse(target.IsFilterViewVisible);
            target.OnToggleFilter(new object());
            Assert.IsTrue(target.IsFilterViewVisible);
        }
        public void MoveToPreviousTest()
        {
            IProjectNotesService             projectNotesService = new ProjectNotesServiceMock(2);
            OverviewWindowViewModel_Accessor target = new OverviewWindowViewModel_Accessor(projectNotesService);

            target.MoveToPrevious();
            Assert.AreEqual(target.CurrentProjectNote, projectNotesService.ProjectNotes.ElementAt(1));
            target.MoveToPrevious();
            Assert.AreEqual(target.CurrentProjectNote, projectNotesService.ProjectNotes.ElementAt(0));
        }
        public void OnShowDetailTest()
        {
            IProjectNotesService             projectNotesService = new ProjectNotesServiceMock(2);
            OverviewWindowViewModel_Accessor target = new OverviewWindowViewModel_Accessor(projectNotesService);

            Assert.IsFalse(target.IsDetailViewVisible);
            Assert.AreEqual(projectNotesService.ProjectNotes.ElementAt(0), target.CurrentProjectNote);
            target.OnShowDetail(projectNotesService.ProjectNotes.ElementAt(1));
            Assert.AreEqual(projectNotesService.ProjectNotes.ElementAt(1), target.CurrentProjectNote);
            Assert.IsTrue(target.IsDetailViewVisible);
        }
Beispiel #9
0
        public void MoveToNextTest()
        {
            IProjectNotesService projectNotesService = new ProjectNotesServiceMock(2);
            var target = new OverviewWindowViewModel_Accessor(projectNotesService, null);

            target.ProjectNotes.MoveCurrentToFirst();
            target.ProjectNotes.MoveCurrentToNext();
            Assert.AreEqual(target.CurrentProjectNote, projectNotesService.ProjectNotes.ElementAt(1));
            target.ProjectNotes.MoveCurrentToNext();
            Assert.AreEqual(target.CurrentProjectNote, projectNotesService.ProjectNotes.ElementAt(0));
        }
        public void TryToAddElementTwiceToFilterTest()
        {
            var projectNotesService = new ProjectNotesServiceMock(5);
            var target = new OverviewWindowViewModel_Accessor(projectNotesService);
            var filter = new MetadataMock(new MetadataTypeMock {
                Name = "Sector"
            }, "Oberkriterium");

            Assert.AreEqual(0, target.Filters.Cast <IMetadata>().Count());
            target.AddFilter(filter);
            Assert.AreEqual(1, target.Filters.Cast <IMetadata>().Count());
            target.AddFilter(filter);
            Assert.AreEqual(1, target.Filters.Cast <IMetadata>().Count());
        }
        public void NavigateToLeftRightCommandTest()
        {
            IProjectNotesService             projectNotesService = new ProjectNotesServiceMock(3);
            OverviewWindowViewModel_Accessor target = new OverviewWindowViewModel_Accessor(projectNotesService);

            target.CurrentProjectNote = projectNotesService.ProjectNotes.ElementAt(0);
            target.NavigateToLeftCommand.Execute(null);
            Assert.AreEqual(target.CurrentProjectNote, projectNotesService.ProjectNotes.ElementAt(2));
            target.NavigateToLeftCommand.Execute(null);
            Assert.AreEqual(target.CurrentProjectNote, projectNotesService.ProjectNotes.ElementAt(1));
            target.NavigateToRightCommand.Execute(null);
            Assert.AreEqual(target.CurrentProjectNote, projectNotesService.ProjectNotes.ElementAt(2));
            target.NavigateToRightCommand.Execute(null);
            Assert.AreEqual(target.CurrentProjectNote, projectNotesService.ProjectNotes.ElementAt(0));
        }
        public void AddAndRemoveAndCallbackFilterTest()
        {
            var projectNotesService = new ProjectNotesServiceMock(5);
            var target = new OverviewWindowViewModel_Accessor(projectNotesService);
            var filter = new MetadataMock(new MetadataTypeMock {
                Name = "Sector"
            }, "Oberkriterium");

            target.AddFilter(filter);
            Assert.IsFalse(target.IsFilterViewVisible);
            Assert.IsFalse(target.IsDetailViewVisible);
            Assert.AreEqual(0, target.ProjectNotes.Count);
            target.RemoveFilter(filter);
            Assert.AreEqual(5, target.ProjectNotes.Count);
        }
Beispiel #13
0
        public void OnShowDetailTest()
        {
            IProjectNotesService projectNotesService = new ProjectNotesServiceMock(2);
            var target = new OverviewWindowViewModel_Accessor(projectNotesService, null);

            Assert.IsFalse(target.IsDetailViewVisible);
            target.ProjectNotes.MoveCurrentToFirst();
            Assert.AreEqual(projectNotesService.ProjectNotes.ElementAt(0), target.CurrentProjectNote);
            var pn = projectNotesService.ProjectNotes[1];

            Assert.AreSame(pn, projectNotesService.ProjectNotes.ElementAt(1));
            target.OnShowDetail(pn);
            Assert.AreSame(pn, target.CurrentProjectNote);
            Assert.IsTrue(target.IsDetailViewVisible);
        }
        public void AddAndRemoveFilterTest()
        {
            var projectNotesService = new ProjectNotesServiceMock(5, "Sector");
            var n      = projectNotesService.Metadata.Keys.ElementAt(0).Name;
            var target = new OverviewWindowViewModel_Accessor(projectNotesService);
            var filter = new MetadataMock(new MetadataTypeMock()
            {
                Name = "Sector"
            }, "Oberkriterium");

            target.AddFilter(filter);
            Assert.AreEqual(target.IsFilterViewVisible, false);
            //Assert.AreEqual(target.ProjectNotes.Cast<IProjectNote>().Count(), 4);
            //target.RemoveFilter(filter);
            //Assert.AreEqual(target.ProjectNotes.Cast<IProjectNote>().Count(), 5);
        }
        public void OverviewWindowViewModelConstructorTest()
        {
            var projectNotesService = new ProjectNotesServiceMock(5);
            var target = new OverviewWindowViewModel_Accessor(projectNotesService);

            Assert.AreEqual(false, target.ReadModeActive);
            Assert.AreEqual(target._normalModeWidth, target.DocumentViewerWidth);
            Assert.AreEqual(false, target.ZoomOutCommand.CanExecute(null));
            Assert.AreEqual(true, target.ZoomInCommand.CanExecute(null));
            target.ZoomInCommand.Execute(null);
            Assert.AreEqual(true, target.ReadModeActive);
            Assert.AreEqual(target._readModeWidth, target.DocumentViewerWidth);
            Assert.AreEqual(false, target.ZoomInCommand.CanExecute(null));
            Assert.AreEqual(true, target.ZoomOutCommand.CanExecute(null));
            target.ZoomOutCommand.Execute(null);
            Assert.AreEqual(false, target.ReadModeActive);
            Assert.AreEqual(target._normalModeWidth, target.DocumentViewerWidth);
            Assert.AreEqual(true, target.ZoomInCommand.CanExecute(null));
            Assert.AreEqual(false, target.ZoomOutCommand.CanExecute(null));
        }
        public void NotifyTest()
        {
            IProjectNotesService projectNotesService = new ProjectNotesServiceMock(4);
            var target = new OverviewWindowViewModel_Accessor(projectNotesService, null);

            var success = false;

            target.add_PropertyChanged((sender, e) => success = true);
            Assert.IsFalse(success);
            target.Notify("Title");
            Assert.IsTrue(success);

            var counter = 0;

            // ReSharper disable AccessToModifiedClosure
            target.add_PropertyChanged((sender, e) => counter += 1);
            // ReSharper restore AccessToModifiedClosure
            target.add_PropertyChanged((sender, e) => counter += 1);
            Assert.AreEqual(counter, 0);
            target.Notify("Title");
            Assert.AreEqual(counter, 2);
            target.Notify("Title");
            Assert.AreEqual(counter, 4);
        }