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);
        }
Example #3
0
        public void OverviewWindowViewModelProjectNotesTest()
        {
            var projectNotesService = new ProjectNotesServiceMock(5);
            var target = new OverviewWindowViewModel(projectNotesService);

            Assert.AreEqual(5, target.ProjectNotes.Count);
        }
        public void DetailWindowViewModelConstructorTest()
        {
            IProjectNotesService           projectNotesService = new ProjectNotesServiceMock(4);
            IProjectNote                   projectNote         = projectNotesService.ProjectNotes[2];
            DetailWindowViewModel_Accessor target = new DetailWindowViewModel_Accessor(projectNotesService, projectNote);

            Assert.AreEqual(target._currentNode.Value, projectNote);
        }
        public void HideDetailsCommandTest()
        {
            IProjectNotesService             projectNotesService = new ProjectNotesServiceMock(2);
            OverviewWindowViewModel_Accessor target = new OverviewWindowViewModel_Accessor(projectNotesService);

            target.HideDetailsCommand.Execute(null);
            Assert.IsFalse(target.IsDetailViewVisible);
        }
Example #6
0
 public void DetailWindowViewModelConstructorTest()
 {
     //_currentNOde
     IProjectNotesService          service     = new ProjectNotesServiceMock(4);
     LinkedListNode <IProjectNote> currentNode = new LinkedListNode <IProjectNote>(service.ProjectNotes[2]);
     IDocumentPaginatorSource      doc         = currentNode.Value.Document;
     DetailWindowViewModel         target      = new DetailWindowViewModel(service, service.ProjectNotes[2]);
 }
        public void OverviewWindowConstructorTest()
        {
            IProjectNotesService    service = new ProjectNotesServiceMock(4);
            OverviewWindowViewModel surfaceWindowViewModel = new OverviewWindowViewModel(service);
            OverviewWindow          target = new OverviewWindow(surfaceWindowViewModel);

            Assert.AreSame(target.DataContext, surfaceWindowViewModel);
        }
Example #8
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);
        }
Example #9
0
        public void OverviewWindowConstructorTest()
        {
            Assert.Inconclusive("TODO: Fix this!"); // TODO: Fix this!
            IProjectNotesService    service = new ProjectNotesServiceMock(4);
            OverviewWindowViewModel surfaceWindowViewModel = new OverviewWindowViewModel(service);
            OverviewWindow          target = new OverviewWindow(surfaceWindowViewModel);

            Assert.AreSame(target.DataContext, surfaceWindowViewModel);
        }
        public void NavigateToRightCommandTest()
        {
            IProjectNotesService           service      = new ProjectNotesServiceMock(4);
            IProjectNote                   subsequentPN = service.ProjectNotes[3];
            DetailWindowViewModel_Accessor target       = new DetailWindowViewModel_Accessor(service, service.ProjectNotes[2]);

            target.NavigateToRightCommand.Execute(this);
            Assert.AreSame(target.Document, subsequentPN.Document);
        }
        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);
        }
        public void DetailWindowConstructorTest()
        {
            IProjectNotesService  service               = new ProjectNotesServiceMock(4);
            IProjectNote          projectNote           = service.ProjectNotes[2];
            DetailWindowViewModel detailWindowViewModel = new DetailWindowViewModel(service, projectNote);
            DetailWindow          target = new DetailWindow(detailWindowViewModel);

            Assert.AreSame(target.DataContext, detailWindowViewModel);
        }
        public void OpenNewWindowTest1()
        {
            var    service = new ProjectNotesServiceMock(5);
            var    target  = new ProjectNoteViewModel_Accessor(service, service.ProjectNotes[0]);
            string test    = "test";

            //target.OpenNewWindow(test); // TODO: Fix this: new DetailWindow(vm); throws an exception; is it possible to create no new DetailWindow in this method?
            Assert.Inconclusive("TODO: Fix this: new DetailWindow(vm); throws an exception; is it possible to create no new DetailWindow in this method?");
        }
        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 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 CloseWindowCommandTest()
        {
            IProjectNotesService  service     = new ProjectNotesServiceMock(4);
            IProjectNote          projectNote = service.ProjectNotes[2];
            DetailWindowViewModel target      = new DetailWindowViewModel(service, projectNote);
            var worked = false;

            target.CloseWindow += () => worked = true;
            target.CloseWindowCommand.Execute(this);
            Assert.IsTrue(worked);
        }
Example #17
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));
        }
Example #18
0
        public void OpenNewWindowTest()
        {
            var    service = new ProjectNotesServiceMock(5);
            var    target  = new ProjectNoteViewModel_Accessor(service, service.ProjectNotes[0]);
            string test    = "test";

            target.OpenNewWindow(test);
            var window = Application.Current.MainWindow;

            Assert.IsNotNull(window);
        }
        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);
        }
Example #20
0
        public void NavigateToLeftTest()
        {
            IProjectNotesService           service    = new ProjectNotesServiceMock(4);
            IProjectNote                   currentPN  = (service.ProjectNotes[2]);
            IProjectNote                   previousPN = (service.ProjectNotes[1]);
            DetailWindowViewModel_Accessor target     = new DetailWindowViewModel_Accessor(service, currentPN);
            object parameter = new object(); // TODO: Initialize to an appropriate value

            target.NavigateToLeft(parameter);
            Assert.AreEqual(previousPN.Document, currentPN.Document);
            //Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
        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));
        }
Example #23
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 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);
        }
        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);
        }