Esempio n. 1
0
        public void TestIdValueIsLoweredForCheck()
        {
            #region Arrange
            var idValue       = "TeSTvALue";
            var directoryUser = new DirectoryUser();
            directoryUser.FirstName    = "Jimmy";
            directoryUser.LastName     = "James";
            directoryUser.EmailAddress = "*****@*****.**";
            DirectorySearchService.Expect(a => a.FindUser("testvalue")).Return(directoryUser);
            new FakeDepartmentalAdminRequests(3, DepartmentalAdminRequestRepository);

            #endregion Arrange

            #region Act
            Controller.TookTraining(idValue);
            #endregion Act

            #region Assert
            Assert.AreEqual("Request created/Updated.", Controller.Message);
            DepartmentalAdminRequestRepository.AssertWasCalled(a => a.EnsurePersistent(Arg <DepartmentalAdminRequest> .Is.Anything));
            var args = (DepartmentalAdminRequest)DepartmentalAdminRequestRepository.GetArgumentsForCallsMadeOn(a => a.EnsurePersistent(Arg <DepartmentalAdminRequest> .Is.Anything))[0][0];
            Assert.AreEqual("testvalue", args.Id);
            Assert.IsTrue(args.AttendedTraining);
            Assert.AreEqual("*****@*****.**", args.Email);
            Assert.AreEqual("Jimmy", args.FirstName);
            Assert.AreEqual("James", args.LastName);
            DirectorySearchService.AssertWasCalled(a => a.FindUser("testvalue"));
            DirectorySearchService.AssertWasNotCalled(a => a.FindUser("TeSTvALue"));
            #endregion Assert
        }
Esempio n. 2
0
        public void TestIdNotFoundThrowsException()
        {
            var thisFar = false;

            try
            {
                #region Arrange

                thisFar = true;
                #endregion Arrange

                #region Act
                Controller.TookTraining("TeSTvALue");
                #endregion Act
            }
            catch (Exception ex)
            {
                Assert.IsTrue(thisFar);
                Assert.IsNotNull(ex);
                Assert.AreEqual("Person requesting Departmental Access ID not found. ID = testvalue", ex.Message);
                DirectorySearchService.AssertWasCalled(a => a.FindUser("testvalue"));
                DirectorySearchService.AssertWasNotCalled(a => a.FindUser("TeSTvALue"));
                throw;
            }
        }
Esempio n. 3
0
        public void TestFindUser1()
        {
            #region Arrange
            const string searchTerm = "TestValue";
            DirectorySearchService.Expect(a => a.FindUser(searchTerm)).Return(null).Repeat.Any();
            #endregion Arrange

            #region Act
            var result = Controller.FindUser(searchTerm)
                         .AssertResultIs <JsonResult>();
            #endregion Act

            #region Assert
            Assert.IsNotNull(result);
            Assert.IsNull(result.Data);
            Assert.AreEqual(JsonRequestBehavior.AllowGet, result.JsonRequestBehavior);
            DirectorySearchService.AssertWasCalled(a => a.FindUser(searchTerm));
            #endregion Assert
        }
Esempio n. 4
0
        public void TestFindUser2()
        {
            #region Arrange
            const string searchTerm = "TestValue";
            AutomapperConfig.Configure();
            var directoryUser = new DirectoryUser();
            directoryUser.EmailAddress = "*****@*****.**";
            directoryUser.EmployeeId   = "EmployeeId";
            directoryUser.FirstName    = "FirstName";
            directoryUser.LastName     = "LastName";
            directoryUser.FullName     = "FullName";
            directoryUser.LoginId      = "LoginId";
            directoryUser.PhoneNumber  = "1 555 555 5555";

            DirectorySearchService.Expect(a => a.FindUser(searchTerm)).Return(directoryUser).Repeat.Any();
            #endregion Arrange

            #region Act
            var result = Controller.FindUser(searchTerm)
                         .AssertResultIs <JsonResult>();
            #endregion Act

            #region Assert
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Data);
            var result2 = (ServiceUser)result.Data;
            Assert.IsNotNull(result2);
            Assert.AreEqual("*****@*****.**", result2.Email);
            Assert.AreEqual("FirstName", result2.FirstName);
            Assert.IsNull(result2.FullNameAndLogin);
            Assert.AreEqual("LastName", result2.LastName);
            Assert.AreEqual("LoginId", result2.Login);
            Assert.AreEqual("1 555 555 5555", result2.Phone);
            Assert.IsNull(result2.Roles);
            Assert.IsNull(result2.Units);

            Assert.AreEqual(JsonRequestBehavior.AllowGet, result.JsonRequestBehavior);
            DirectorySearchService.AssertWasCalled(a => a.FindUser(searchTerm));
            #endregion Assert
        }