public void CanCreateFormViewModel()
        {
            // Establish Context
            var viewModelToExpect = new RequestEstimateFormViewModel();

            // Act
            RequestEstimateFormViewModel viewModelRetrieved =
                _requestEstimateManagementService.CreateFormViewModel();

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.RequestEstimate.ShouldBeNull();
        }
        public void CanInitCreate()
        {
            // Establish Context
            var viewModel = new RequestEstimateFormViewModel();

            _requestEstimateManagementService.Expect(r => r.CreateFormViewModel())
                .Return(viewModel);

            // Act
            ViewResult result = _requestEstimatesController.Create().AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as RequestEstimateFormViewModel).ShouldNotBeNull();
            (result.ViewData.Model as RequestEstimateFormViewModel).RequestEstimate.ShouldBeNull();
        }
        public void CanCreateFormViewModelForRequestEstimate()
        {
            // Establish Context
            var viewModelToExpect = new RequestEstimateFormViewModel();

            RequestEstimate requestEstimate =
                RequestEstimateInstanceFactory.CreateValidTransientRequestEstimate();

            _requestEstimateRepository.Expect(r => r.Get(1))
                .Return(requestEstimate);

            // Act
            RequestEstimateFormViewModel viewModelRetrieved =
                _requestEstimateManagementService.CreateFormViewModelFor(1);

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.RequestEstimate.ShouldNotBeNull();
            viewModelRetrieved.RequestEstimate.ShouldEqual(requestEstimate);
        }
        public void CannotUpdateInvalidRequestEstimateFromForm()
        {
            // Establish Context
            var requestEstimateFromForm = new RequestEstimate();
            var viewModelToExpect = new RequestEstimateFormViewModel();
            var testUser = PersonInstanceFactory.CreateValidTransientPerson();
            testUser.SetAssignedIdTo(1);

            _authenticationProvider.Expect(r => r.GetLoggedInUser()).Return("testuser");
            _personManagementService.Expect(r => r.GetByUserName(Arg<string>.Is.Anything)).Return(testUser);
            _requestEstimateManagementService.Expect(r => r.UpdateWith(requestEstimateFromForm, 0))
                .Return(ActionConfirmation.CreateFailureConfirmation("not updated"));
            _requestEstimateManagementService.Expect(r => r.CreateFormViewModelFor(requestEstimateFromForm))
                .Return(viewModelToExpect);

            // Act
            ViewResult result =
                _requestEstimatesController.Edit(requestEstimateFromForm).AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as RequestEstimateFormViewModel).ShouldNotBeNull();
        }