Example #1
0
        public void CanUpdateWithValidApplicationFromForm()
        {
            // Establish Context
            Application validApplicationFromForm =
                ApplicationInstanceFactory.CreateValidTransientApplication();
            var validPerson = PersonInstanceFactory.CreateValidTransientPerson();

            validApplicationFromForm.LastUpdateUser = 1;
            validPerson.RoleId = 2;

            // Intentionally empty to ensure successful transfer of values
            var applicationFromDb = new Application {
                ApplicationName = "Application Name 1", SupportTeamId = 1
            };

            _personManagementService.Expect(r => r.Get(Arg <int> .Is.Anything)).Return(validPerson);

            _applicationRepository.Expect(r => r.Get(Arg <int> .Is.Anything))
            .Return(applicationFromDb);
            _personManagementService.Expect(r => r.Get(Arg <int> .Is.Anything)).Return(validPerson);

            // Act
            ActionConfirmation confirmation =
                _applicationManagementService.UpdateWith(validApplicationFromForm, 1);

            // Assert
            confirmation.ShouldNotBeNull();
            confirmation.WasSuccessful.ShouldBeTrue();
            confirmation.Value.ShouldNotBeNull();
            confirmation.Value.ShouldEqual(applicationFromDb);
            confirmation.Value.ShouldEqual(validApplicationFromForm);
        }
Example #2
0
        public void CanCreateFormViewModel()
        {
            // Establish Context
            var viewModelToExpect = new TimeEntryFormViewModel();

            _personManagementService.Expect(x => x.GetByUserName(Arg <string> .Is.Anything)).Return(
                PersonInstanceFactory.CreateValidTransientPerson());
            //_timeEntryRepository.Expect(x => x.GetRecentRequests(Arg<int>.Is.Anything)).Return(null);

            // Act
            TimeEntryFormViewModel viewModelRetrieved =
                _timeEntryManagementService.CreateFormViewModel(DateTime.Today, "testuser");

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.TimeEntry.ShouldBeNull();
        }
        public void CanCreateValidTimeEntryFromForm()
        {
            // Establish Context
            var timeEntryFromForm = new TimeEntry();

            _timeEntryManagementService.Expect(r => r.SaveOrUpdate(timeEntryFromForm))
            .Return(ActionConfirmation.CreateSuccessConfirmation("saved"));

            _authenticationProvider.Expect(x => x.GetLoggedInUser()).Return("testuser");
            _personManagementService.Expect(x => x.GetByUserName(Arg <string> .Is.Anything)).Return(
                PersonInstanceFactory.CreateValidTransientPerson());

            // Act
            RedirectToRouteResult redirectResult =
                _timeEntriesController.Create(timeEntryFromForm)
                .AssertActionRedirect().ToAction("Index");

            // Assert
            _timeEntriesController.TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()].ToString()
            .ShouldEqual("saved");
        }
Example #4
0
        public void CanCreateValidAgencyFromForm()
        {
            // Establish Context
            var agencyFromForm = new Agency();
            var testUser       = new Person();

            testUser.SetAssignedIdTo(1);
            _agencyManagementService.Expect(r => r.SaveOrUpdate(agencyFromForm))
            .Return(ActionConfirmation.CreateSuccessConfirmation("saved"));

            _authenticationProvider.Expect(r => r.GetLoggedInUser()).Return("user1");
            _personManagementService.Expect(r => r.GetByUserName("user1")).Return(testUser);
            // Act
            RedirectToRouteResult redirectResult =
                _agenciesController.Create(agencyFromForm)
                .AssertActionRedirect().ToAction("Search");

            // Assert
            _agenciesController.TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()].ToString()
            .ShouldEqual("saved");
        }
        public void CanGetIncompleteWeeklyTimeForAllUsers()
        {
            IList <TimeEntryAudit> timeEntriesToExpect = new List <TimeEntryAudit>();
            IList <Person>         personsToExpect     = new List <Person>();

            TimeEntryAudit timeEntryAudit =
                TimeEntryAuditInstanceFactory.CreateValidTransientTimeEntryAudit();
            Person person = PersonInstanceFactory.CreateValidTransientPerson();

            personsToExpect.Add(person);

            _personManagementService.Expect(r => r.GetActiveStaff()).Return(personsToExpect);

            IList <TimeEntryAuditDto> auditDtos =
                _timeEntryAuditManagementService.GetIncompleteWeeklyTimeForAllUsers(Dates.GetPreviousSaturday());

            foreach (var auditDto in auditDtos)
            {
                Console.WriteLine(String.Format("UserID:{0}, Hours:{1}", auditDto.UserId, auditDto.Hours));
                Assert.That(float.Parse(auditDto.Hours, CultureInfo.InvariantCulture) < 40);
            }
        }