public void NoDirectReportsFoundNullLoginName()
        {
            serviceLocator.Register <IHRManager>(typeof(MockHRManager));

            this.mockView.Web = web;
            //LoginName not being set here
            this.mockView.ShowLogin = false;

            DirectReportsPresenter presenter = new DirectReportsPresenter(this.mockView);

            presenter.SetDirectReportsSource("http://localhost/training/manage.aspx");

            //assert error message
            Assert.IsNull(this.mockView.DirectReports);
            Assert.AreEqual("An unexpected error occurred.", this.mockView.DirectReportsMessage);
        }
        public void NoDirectReportsFoundNullWeb()
        {
            serviceLocator.Register <IHRManager>(typeof(MockHRManager));

            //Web not being set here
            this.mockView.LoginName = string.Format(@"{0}\{1}", Environment.MachineName, "spgmanager");
            this.mockView.ShowLogin = false;

            DirectReportsPresenter presenter = new DirectReportsPresenter(this.mockView);

            presenter.SetDirectReportsSource("http://localhost/training/manage.aspx");

            //assert error message
            Assert.IsNull(this.mockView.DirectReports);
            Assert.AreEqual("An unexpected error occurred.", this.mockView.DirectReportsMessage);
        }
        public void NoDirectReportsFoundInvalidUser()
        {
            serviceLocator.Register <IHRManager>(typeof(MockHRManager));

            mockView.Web       = web;
            mockView.LoginName = string.Format(@"{0}\{1}", Environment.MachineName, "newmanager");
            mockView.ShowLogin = false;

            DirectReportsPresenter presenter = new DirectReportsPresenter(mockView);

            presenter.SetDirectReportsSource("http://localhost/training/manage.aspx");

            //assert error message
            Assert.IsNull(mockView.DirectReports);
            Assert.AreEqual("No direct reports were found.", mockView.DirectReportsMessage);
        }
        public void SetDirectReportsTestWithShowLogin()
        {
            serviceLocator.Register <IHRManager>(typeof(MockHRManager));

            mockView.Web       = web;
            mockView.LoginName = string.Format(@"{0}\{1}", Environment.MachineName, "spgmanager");
            mockView.ShowLogin = true;

            DirectReportsPresenter presenter = new DirectReportsPresenter(mockView);

            presenter.SetDirectReportsSource("http://localhost/training/manage.aspx");

            //assert direct reports
            Assert.IsNotNull(mockView.DirectReports);
            Assert.AreEqual("/_layouts/userdisp.aspx?ID=", mockView.UserDisplayUrl);
            Assert.AreEqual("&Source=http://localhost/training/manage.aspx", mockView.SourceUrl);
            Assert.AreEqual(1, mockView.DirectReports.Count);
            Assert.AreEqual("You have 1 direct report(s).", mockView.DirectReportsMessage);
        }
        public void NoDirectReportsFound()
        {
            serviceLocator.Register <IHRManager>(typeof(MockHRManager));

            SPWeb web = CreateMockSPWeb(true, true);

            this.mockView.Web       = web;
            this.mockView.LoginName = string.Format(@"{0}\{1}", Environment.MachineName, "newemployee");
            this.mockView.ShowLogin = false;

            DirectReportsPresenter presenter = new DirectReportsPresenter(this.mockView);

            presenter.SetDirectReportsSource("http://localhost/training/manage.aspx");

            //assert error message
            Assert.IsNull(this.mockView.DirectReports);
            Assert.AreEqual("No direct reports were found.", this.mockView.DirectReportsMessage);
            MockManager.Verify();
        }
        public void SetDirectReportsTestWithShowLogin()
        {
            serviceLocator.Register <IHRManager>(typeof(MockHRManager));

            SPWeb web = CreateMockSPWeb(false, true);

            this.mockView.Web       = web;
            this.mockView.LoginName = string.Format(@"{0}\{1}", Environment.MachineName, "spgmanager");
            this.mockView.ShowLogin = true;

            DirectReportsPresenter presenter = new DirectReportsPresenter(this.mockView);

            presenter.SetDirectReportsSource("http://localhost/training/manage.aspx");

            //assert direct reports
            Assert.IsNotNull(this.mockView.DirectReports);
            Assert.AreEqual("/_layouts/userdisp.aspx?ID=", this.mockView.UserDisplayUrl);
            Assert.AreEqual("&Source=http://localhost/training/manage.aspx", this.mockView.SourceUrl);
            Assert.AreEqual <int>(1, this.mockView.DirectReports.Count);
            Assert.AreEqual("SPG Employee (" + string.Format(@"{0}\{1}", Environment.MachineName, "spgemployee") + ")", this.mockView.DirectReports[1]);
            Assert.AreEqual("You have 1 direct report(s).", this.mockView.DirectReportsMessage);
            MockManager.Verify();
        }