Exemplo n.º 1
0
        public void Constructor_RootGroupsShouldBeAnObservableCollectionOfReportGroupFolders()
        {
            //Arrange
            var mockDomainClient = new Mock <FakeDomainClient>();

            mockDomainClient.Setup(dc => dc.Query(It.Is <EntityQuery>(query => query.EntityType == typeof(ReportGroup))))
            .Returns(() => new Entity[]
            {
                new ReportGroup {
                }
            }.AsQueryable());

            //Act
            ReportWizardContext        context   = new ReportWizardContext(mockDomainClient.Object);
            SelectReportGroupViewModel viewModel = new SelectReportGroupViewModel(context);

            ////Assert
            EnqueueConditional(() =>  //Wait until the load has finished
                               context.IsLoading != null);

            EnqueueCallback(() =>
            {
                Assert.IsInstanceOfType(viewModel.RootGroups,
                                        typeof(ObservableCollection <ReportGroupFolder>), "RootGroups is not an observablecollection of report group folders");
            });
            EnqueueTestComplete();
        }
Exemplo n.º 2
0
        public void CancelCommand_ShouldSetTheDialogResultToFalse()
        {
            //Arrange
            var  mockDomainClient = new Mock <FakeDomainClient>();
            bool loadExecuted     = false;

            mockDomainClient.Setup(dc => dc.Query(It.Is <EntityQuery>(query => query.EntityType == typeof(ReportGroup))))
            .Callback(() => loadExecuted = true)
            .Returns(() => new Entity[]
            {
                new ReportGroup {
                }
            }.AsQueryable());

            //Act
            ReportWizardContext        context   = new ReportWizardContext(mockDomainClient.Object);
            SelectReportGroupViewModel viewModel = new SelectReportGroupViewModel(context);

            ////Assert
            EnqueueConditional(() =>  //Wait until the load has finished
                               context.IsLoading == false);


            EnqueueCallback(() =>
            {
                viewModel.CancelCommand.Execute(null);
                Assert.IsTrue(viewModel.DialogResult.Value == false, "CancelCommand has not set the dialog result to false");
            });
            EnqueueTestComplete();
        }
Exemplo n.º 3
0
        public void Constructor_CancelCommandShouldBeARelayCommand()
        {
            //Arrange
            var mockDomainClient = new Mock <FakeDomainClient>();

            mockDomainClient.Setup(dc => dc.Query(It.Is <EntityQuery>(query => query.EntityType == typeof(ReportGroup))))
            .Returns(() => new Entity[]
            {
                new ReportGroup {
                }
            }.AsQueryable());

            //Act
            ReportWizardContext        context   = new ReportWizardContext(mockDomainClient.Object);
            SelectReportGroupViewModel viewModel = new SelectReportGroupViewModel(context);

            ////Assert
            EnqueueConditional(() =>  //Wait until OkCommand has been initialised
                               viewModel.CancelCommand != null);

            EnqueueCallback(() => //test that the save command is a relay command
            {
                Assert.IsInstanceOfType(viewModel.CancelCommand,
                                        typeof(RelayCommand), "CancelCommand is not a RelayCommand");
            });
            EnqueueTestComplete();
        }
Exemplo n.º 4
0
        public void DialogResult_ShouldRaisePropertyChangeWhenAltered()
        {
            //Arrange
            var  mockDomainClient = new Mock <FakeDomainClient>();
            bool loadExecuted     = false;

            mockDomainClient.Setup(dc => dc.Query(It.Is <EntityQuery>(query => query.EntityType == typeof(ReportGroup))))
            .Callback(() => loadExecuted = true)
            .Returns(() => new Entity[]
            {
                new ReportGroup {
                }
            }.AsQueryable());

            //Act
            ReportWizardContext        context   = new ReportWizardContext(mockDomainClient.Object);
            SelectReportGroupViewModel viewModel = new SelectReportGroupViewModel(context);

            ////Assert
            EnqueueConditional(() =>  //Wait until the load has finished
                               context.IsLoading == false);

            EnqueueCallback(() =>
            {
                viewModel.AssertRaisesPropertyChangedFor("DialogResult");
            });
            EnqueueTestComplete();
        }
Exemplo n.º 5
0
        public void OkCommandCanExecute_ShouldBeTrueIfGreenFolderSelecetedAndReportNameHasBeenEntered()
        {
            //Arrange
            var  mockDomainClient = new Mock <FakeDomainClient>();
            bool loadExecuted     = false;

            mockDomainClient.Setup(dc => dc.Query(It.Is <EntityQuery>(query => query.EntityType == typeof(ReportGroup))))
            .Callback(() => loadExecuted = true)
            .Returns(() => new Entity[]
            {
                new ReportGroup {
                }
            }.AsQueryable());

            //Act
            ReportWizardContext        context   = new ReportWizardContext(mockDomainClient.Object);
            SelectReportGroupViewModel viewModel = new SelectReportGroupViewModel(context);

            ////Assert
            EnqueueConditional(() =>  //Wait until the load has finished
                               context.IsLoading == false);

            EnqueueCallback(() =>
            {
                viewModel.ReportName          = "PopulatedReportName"; //report name populated
                viewModel.SelectedReportGroup = new ReportGroupFolder  //do  have access to this folder
                {
                    AccessLevel = ReportGroupAccessLevelType.Admin
                };

                Assert.IsTrue(viewModel.OKCommand.CanExecute(null) == true, "OkCommand should be enabled if an accessible folder has been selected and the report name has been filled in");
            });
            EnqueueTestComplete();
        }
Exemplo n.º 6
0
        public void OkCommandCanExecute_ShouldBeFalseIfNoFolderHasBeenSelected()
        {
            //Arrange
            var  mockDomainClient = new Mock <FakeDomainClient>();
            bool loadExecuted     = false;

            mockDomainClient.Setup(dc => dc.Query(It.Is <EntityQuery>(query => query.EntityType == typeof(ReportGroup))))
            .Callback(() => loadExecuted = true)
            .Returns(() => new Entity[]
            {
                new ReportGroup {
                }
            }.AsQueryable());

            //Act
            ReportWizardContext        context   = new ReportWizardContext(mockDomainClient.Object);
            SelectReportGroupViewModel viewModel = new SelectReportGroupViewModel(context);

            ////Assert
            EnqueueConditional(() =>  //Wait until the load has finished
                               context.IsLoading == false);

            EnqueueCallback(() =>
            {
                viewModel.ReportName          = "TestReportName"; //report name populated
                viewModel.SelectedReportGroup = null;             //no folder selected

                Assert.IsTrue(viewModel.OKCommand.CanExecute(null) == false, "OkCommand should be disabled if no folder has been selected");
            });
            EnqueueTestComplete();
        }
Exemplo n.º 7
0
        public void Constructor_ShouldAttemptToLoadReportGroupsForUser()
        {
            //Arrange
            var  mockDomainClient = new Mock <FakeDomainClient>();
            bool loadExecuted     = false;

            mockDomainClient.Setup(dc => dc.Query(It.Is <EntityQuery>(query => query.EntityType == typeof(ReportGroup))))
            .Callback(() => loadExecuted = true)
            .Returns(() => new Entity[]
            {
                new ReportGroup {
                }
            }.AsQueryable());

            //Act
            ReportWizardContext        context   = new ReportWizardContext(mockDomainClient.Object);
            SelectReportGroupViewModel viewModel = new SelectReportGroupViewModel(context);

            ////Assert
            EnqueueConditional(() =>  //Wait until the load has finished
                               context.IsLoading == false);

            EnqueueCallback(() =>
            {
                Assert.IsTrue(loadExecuted, "The load was not called"); //Test if the method was executed
            });
            EnqueueTestComplete();
        }
Exemplo n.º 8
0
        public void GetReportGroupsForUserCallback_RootGroupsGetsPopulatedWithTheReportGroups()
        {
            //Arrange
            var  mockDomainClient = new Mock <FakeDomainClient>();
            bool loadExecuted     = false;

            mockDomainClient.Setup(dc => dc.Query(It.Is <EntityQuery>(query => query.EntityType == typeof(ReportGroup))))
            .Callback(() => loadExecuted = true)
            .Returns(() => new Entity[]
            {
                new ReportGroup {
                    AccessLevel = ReportGroupAccessLevelType.None,
                    Name        = "ESF2007MIReports",
                    PathName    = "ESF2007MIReports/"
                },

                new ReportGroup {
                    AccessLevel = ReportGroupAccessLevelType.None,
                    Name        = "Sub Committees",
                    ParentPath  = "ESF2007MIReports/",
                    PathName    = "ESF2007MIReports/Sub Committee/"
                }
            }.AsQueryable());

            //Act
            ReportWizardContext        context   = new ReportWizardContext(mockDomainClient.Object);
            SelectReportGroupViewModel viewModel = new SelectReportGroupViewModel(context);

            ////Assert
            EnqueueConditional(() =>  //Wait until the load has finished
                               context.IsLoading == false);

            EnqueueCallback(() =>
            {
                Assert.IsTrue(viewModel.RootGroups.Count == 2, "RootGroups was not populated with the correct number of ReportGroupFolders"); //Test if the method was executed
            });
            EnqueueTestComplete();
        }