public void Handle_GivenValidKey_ReturnsAgencySummaryDto() { var handler = new GetAgencySummaryByKeyRequestHandler() { SessionProvider = SessionProvider }; // When you do Agatha Request Handler testing, always declare the request as the base class type Agatha.Common.Request Request request = new GetAgencySummaryByKeyRequest { Key = SafeHarborAgency.Key }; Response response = handler.Handle(request); var dtoResponse = response as GetAgencySummaryByKeyResponse; AgencySummaryDto agencySummaryDto = dtoResponse.AgencySummaryDto; Assert.AreEqual("Safe Harbor", agencySummaryDto.DisplayName); AgencyAddressAndPhoneDto addressDto = agencySummaryDto.AddressesAndPhones.Single(); Assert.AreEqual("123 Safe Harbor Way", addressDto.FirstStreetAddress); Assert.AreEqual(2, addressDto.PhoneNumbers.Count); // Make sure that we are only returning active contacts Assert.AreEqual(1, agencySummaryDto.AgencyContacts.Count()); AgencyIdentifierDto agencyIdentifierDto = agencySummaryDto.AgencyIdentifiers.Single(); Assert.AreEqual("154975646", agencyIdentifierDto.IdentifierNumber); }
private void MapAgencyPhone(AgencyAddressAndPhone agencyAddressAndPhone, AgencyAddressAndPhoneDto agencyAddressAndPhoneDto) { _mappingResult &= new AggregateNodeCollectionMapper <AgencyPhoneDto, AgencyAddressAndPhone, AgencyPhone> ( agencyAddressAndPhoneDto.PhoneNumbers, agencyAddressAndPhone, agencyAddressAndPhone.PhoneNumbers).MapAddedItem(AddAgencyPhone) .MapChangedItem( ChangeAgencyPhone).MapRemovedItem(RemoveAgencyPhone).Map(); }
private void AddAgencyAddress(AgencyAddressAndPhoneDto agencyAddressAndPhoneDto, Agency agency) { var agencyAddressType = _mappingHelper.MapLookupField <AgencyAddressType> (agencyAddressAndPhoneDto.AgencyAddressType); var stateProvince = _mappingHelper.MapLookupField <StateProvince> (agencyAddressAndPhoneDto.StateProvince); var countyArea = _mappingHelper.MapLookupField <CountyArea> (agencyAddressAndPhoneDto.CountyArea); var country = _mappingHelper.MapLookupField <Country> (agencyAddressAndPhoneDto.Country); var agencyAddress = agency.AddAddressAndPhone( new AgencyAddress( agencyAddressType, new AddressBuilder().WithFirstStreetAddress(agencyAddressAndPhoneDto.FirstStreetAddress).WithSecondStreetAddress( agencyAddressAndPhoneDto.SecondStreetAddress).WithCityName(agencyAddressAndPhoneDto.CityName).WithCountyArea( countyArea).WithStateProvince(stateProvince) .WithCountry(country).WithPostalCode(new PostalCode(agencyAddressAndPhoneDto.PostalCode)))); MapAgencyPhone(agencyAddress, agencyAddressAndPhoneDto); }
private void RemoveAgencyAddress( AgencyAddressAndPhoneDto agencyAddressAndPhoneDto, Agency agency, AgencyAddressAndPhone agencyAddressAndPhone) { agency.RemoveAddress(agencyAddressAndPhone); }