public void CanShowTimeEntry() { // Establish Context TimeEntry timeEntry = TimeEntryInstanceFactory.CreateValidTransientTimeEntry(); _timeEntryManagementService.Expect(r => r.Get(1)) .Return(timeEntry); // Act ViewResult result = _timeEntriesController.Show(1).AssertViewRendered(); // Assert result.ViewData.Model.ShouldNotBeNull(); (result.ViewData.Model as TimeEntry).ShouldNotBeNull(); (result.ViewData.Model as TimeEntry).ShouldEqual(timeEntry); }
public void CanSaveOrUpdateValidTimeEntry() { // Establish Context TimeEntry validTimeEntry = TimeEntryInstanceFactory.CreateValidTransientTimeEntry(); // Act ActionConfirmation confirmation = _timeEntryManagementService.SaveOrUpdate(validTimeEntry); // Assert confirmation.ShouldNotBeNull(); confirmation.WasSuccessful.ShouldBeTrue(); confirmation.Value.ShouldNotBeNull(); confirmation.Value.ShouldEqual(validTimeEntry); }
public void CanGetTimeEntry() { // Establish Context TimeEntry timeEntryToExpect = TimeEntryInstanceFactory.CreateValidTransientTimeEntry(); WrmsSystem system = WrmsSystemInstanceFactory.CreateValidTransientWrmsSystem(); _timeEntryRepository.Expect(r => r.Get(Arg <int> .Is.Anything)) .Return(timeEntryToExpect); _wrmsSystemRepository.Expect(r => r.GetByRequestId(Arg <int> .Is.Anything)) .Return(system); // Act TimeEntry timeEntryRetrieved = _timeEntryManagementService.Get(Arg <int> .Is.Anything); // Assert timeEntryRetrieved.ShouldNotBeNull(); timeEntryRetrieved.ShouldEqual(timeEntryToExpect); }
public void CanCreateFormViewModelForTimeEntry() { // Establish Context var viewModelToExpect = new TimeEntryFormViewModel(); _personManagementService.Expect(x => x.GetByUserName(Arg <string> .Is.Anything)).Return( PersonInstanceFactory.CreateValidTransientPerson()); TimeEntry timeEntry = TimeEntryInstanceFactory.CreateValidTransientTimeEntry(); _timeEntryRepository.Expect(r => r.Get(Arg <int> .Is.Anything)) .Return(timeEntry); // Act TimeEntryFormViewModel viewModelRetrieved = _timeEntryManagementService.CreateFormViewModelFor(1, "testuser"); // Assert viewModelRetrieved.ShouldNotBeNull(); viewModelRetrieved.TimeEntry.ShouldNotBeNull(); viewModelRetrieved.TimeEntry.ShouldEqual(timeEntry); }
public void CanUpdateWithValidTimeEntryFromForm() { // Establish Context TimeEntry validTimeEntryFromForm = TimeEntryInstanceFactory.CreateValidTransientTimeEntry(); // Intentionally empty to ensure successful transfer of values var timeEntryFromDb = new TimeEntry(); _timeEntryRepository.Expect(r => r.Get(1)) .Return(timeEntryFromDb); // Act ActionConfirmation confirmation = _timeEntryManagementService.UpdateWith(validTimeEntryFromForm, 1); // Assert confirmation.ShouldNotBeNull(); confirmation.WasSuccessful.ShouldBeTrue(); confirmation.Value.ShouldNotBeNull(); confirmation.Value.ShouldEqual(timeEntryFromDb); confirmation.Value.ShouldEqual(validTimeEntryFromForm); }
public void CanGetAllTimeEntries() { // Establish Context IList <TimeEntry> timeEntriesToExpect = new List <TimeEntry>(); TimeEntry timeEntry = TimeEntryInstanceFactory.CreateValidTransientTimeEntry(); timeEntriesToExpect.Add(timeEntry); _timeEntryRepository.Expect(r => r.GetAll()) .Return(timeEntriesToExpect); // Act IList <TimeEntry> timeEntriesRetrieved = _timeEntryManagementService.GetAll(); // Assert timeEntriesRetrieved.ShouldNotBeNull(); timeEntriesRetrieved.Count.ShouldEqual(1); timeEntriesRetrieved[0].ShouldNotBeNull(); timeEntriesRetrieved[0].ShouldEqual(timeEntry); }