public void TestAddAddressPostReturnsViewWhenInvalid()
        {
            #region Arrange
            new FakeStates(3, StateRepository);
            new FakeWorkgroups(3, WorkgroupRepository);
            var address = CreateValidEntities.WorkgroupAddress(4);
            address.Name = string.Empty;
            #endregion Arrange

            #region Act
            var result = Controller.AddAddress(2, address)
                         .AssertViewRendered()
                         .WithViewData <WorkgroupAddressViewModel>();
            #endregion Act

            #region Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.WorkgroupAddress.Id);
            Assert.AreEqual(2, result.Workgroup.Id);
            Assert.AreEqual(2, result.WorkgroupAddress.Workgroup.Id);
            Assert.AreEqual(3, result.States.Count());
            WorkgroupRepository.AssertWasNotCalled(a => a.EnsurePersistent(Arg <Workgroup> .Is.Anything));
            Assert.AreEqual("Address not valid", Controller.ErrorMessage);
            WorkgroupAddressService.AssertWasNotCalled(a => a.CompareAddress(Arg <WorkgroupAddress> .Is.Anything, Arg <WorkgroupAddress> .Is.Anything));
            #endregion Assert
        }
        public void TestAddAddressPostRedirectsIfWorkgroupNotFound()
        {
            #region Arrange
            new FakeWorkgroups(3, WorkgroupRepository);
            #endregion Arrange

            #region Act
            Controller.AddAddress(4, new WorkgroupAddress())
            .AssertActionRedirect()
            .ToAction <WorkgroupController>(a => a.Index(false));
            #endregion Act

            #region Assert
            Assert.AreEqual("Workgroup could not be found.", Controller.ErrorMessage);
            WorkgroupAddressService.AssertWasNotCalled(a => a.CompareAddress(Arg <WorkgroupAddress> .Is.Anything, Arg <WorkgroupAddress> .Is.Anything));
            #endregion Assert
        }