Пример #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
        }
Пример #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;
            }
        }