public void CreateChildAgency_WithParentAgency_CreatesAChildAgency() { var agencyRepository = new Mock<IAgencyRepository>(); var agencyFactory = new AgencyFactory(agencyRepository.Object); var parentAgency = new Mock<Agency>(); var agencyType = new Mock<AgencyType>(); Agency agency = agencyFactory.CreateChildAgency( new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName( new AgencyNameBuilder().WithLegalName(LegalName)), parentAgency.Object); Assert.AreSame(agency.ParentAgency, parentAgency.Object); }
public void CreateChildAgency_WithParentAgency_AgencyIsEditable() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var agencyRepository = new Mock<IAgencyRepository>(); var agencyFactory = new AgencyFactory(agencyRepository.Object); var parentAgency = new Mock<Agency>(); var agencyType = new Mock<AgencyType>(); Agency agency = agencyFactory.CreateChildAgency( new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName( new AgencyNameBuilder().WithLegalName(LegalName)), parentAgency.Object); agency.ReviseAgencyProfile(new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName( new AgencyNameBuilder().WithLegalName(LegalName).WithDisplayName("My Agency Display Name"))); } }
public void CreateChildAgency_WithParentAgency_AgencyIsMadePersistent() { bool isPersistent = false; var agencyRepository = new Mock<IAgencyRepository>(); agencyRepository .Setup(a => a.MakePersistent(It.IsAny<Agency>())) .Callback(() => isPersistent = true); var agencyFactory = new AgencyFactory(agencyRepository.Object); var parentAgency = new Mock<Agency>(); var agencyType = new Mock<AgencyType>(); agencyFactory.CreateChildAgency( new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName( new AgencyNameBuilder().WithLegalName(LegalName)), parentAgency.Object); Assert.IsTrue(isPersistent); }
public void CreateChildAgency_WithNullParentAgency_ThrowsArgumentException() { var agencyRepository = new Mock<IAgencyRepository>(); var agencyFactory = new AgencyFactory(agencyRepository.Object); var agencyType = new Mock<AgencyType>(); agencyFactory.CreateChildAgency(new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName( new AgencyNameBuilder().WithLegalName(LegalName)), null); }