Ejemplo n.º 1
0
        public void CanSaveOrUpdateValidHost()
        {
            // Establish Context
            Host validHost =
                HostInstanceFactory.CreateValidTransientHost();

            // Act
            ActionConfirmation confirmation =
                _hostManagementService.SaveOrUpdate(validHost);

            // Assert
            confirmation.ShouldNotBeNull();
            confirmation.WasSuccessful.ShouldBeTrue();
            confirmation.Value.ShouldNotBeNull();
            confirmation.Value.ShouldEqual(validHost);
        }
Ejemplo n.º 2
0
        public void CanGetHost()
        {
            // Establish Context
            Host hostToExpect =
                HostInstanceFactory.CreateValidTransientHost();

            _hostRepository.Expect(r => r.Get(1))
            .Return(hostToExpect);

            // Act
            Host hostRetrieved =
                _hostManagementService.Get(1);

            // Assert
            hostRetrieved.ShouldNotBeNull();
            hostRetrieved.ShouldEqual(hostToExpect);
        }
Ejemplo n.º 3
0
        public void CanShowHost()
        {
            // Establish Context
            Host host =
                HostInstanceFactory.CreateValidTransientHost();

            hostManagementService.Expect(r => r.Get(1))
            .Return(host);

            // Act
            ViewResult result = hostsController.Show(1).AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as Host).ShouldNotBeNull();
            (result.ViewData.Model as Host).ShouldEqual(host);
        }
Ejemplo n.º 4
0
        public void CanCreateFormViewModelForHost()
        {
            // Establish Context
            var viewModelToExpect = new HostFormViewModel();

            Host host =
                HostInstanceFactory.CreateValidTransientHost();

            _hostRepository.Expect(r => r.Get(1))
            .Return(host);

            // Act
            HostFormViewModel viewModelRetrieved =
                _hostManagementService.CreateFormViewModelFor(1);

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.Host.ShouldNotBeNull();
            viewModelRetrieved.Host.ShouldEqual(host);
        }
Ejemplo n.º 5
0
        public void CanGetAllHosts()
        {
            // Establish Context
            IList <Host> hostsToExpect = new List <Host>();

            Host host =
                HostInstanceFactory.CreateValidTransientHost();

            hostsToExpect.Add(host);

            _hostRepository.Expect(r => r.GetAll(Arg <string> .Is.Anything, Arg <string> .Is.Anything))
            .Return(hostsToExpect);

            // Act
            IList <Host> hostsRetrieved =
                _hostManagementService.GetAll();

            // Assert
            hostsRetrieved.ShouldNotBeNull();
            hostsRetrieved.Count.ShouldEqual(1);
            hostsRetrieved[0].ShouldNotBeNull();
            hostsRetrieved[0].ShouldEqual(host);
        }
Ejemplo n.º 6
0
        public void CanUpdateWithValidHostFromForm()
        {
            // Establish Context
            Host validHostFromForm =
                HostInstanceFactory.CreateValidTransientHost();

            // Intentionally empty to ensure successful transfer of values
            var hostFromDb = new Host();

            _hostRepository.Expect(r => r.Get(1))
            .Return(hostFromDb);

            // Act
            ActionConfirmation confirmation =
                _hostManagementService.UpdateWith(validHostFromForm, 1);

            // Assert
            confirmation.ShouldNotBeNull();
            confirmation.WasSuccessful.ShouldBeTrue();
            confirmation.Value.ShouldNotBeNull();
            confirmation.Value.ShouldEqual(hostFromDb);
            confirmation.Value.ShouldEqual(validHostFromForm);
        }