public void CanCreateAddress() { var address = addressBuilder .Create("address 1", "town", nonUkId) .ToAddress(); Assert.IsAssignableFrom <Address>(address); }
public void ToModel_Address_ReturnsAddressModel() { Address address = AddressBuilder .Create() .WithLine1(Guid.NewGuid().ToString()) .WithLine2(Guid.NewGuid().ToString()) .WithLine3(Guid.NewGuid().ToString()) .WithLine4(Guid.NewGuid().ToString()) .WithLine5(Guid.NewGuid().ToString()) .WithTown(Guid.NewGuid().ToString()) .WithCounty(Guid.NewGuid().ToString()) .WithPostcode(Guid.NewGuid().ToString()) .WithCountry(Guid.NewGuid().ToString()) .Build(); var actual = address.ToModel(); AddressModel expected = new AddressModel { Line1 = address.Line1, Line2 = address.Line2, Line3 = address.Line3, Line4 = address.Line4, Line5 = address.Line5, Town = address.Town, County = address.County, Postcode = address.Postcode, Country = address.Country }; actual.Should().BeEquivalentTo(expected); }
public async Task CreateAsync_CreatesOrganisationWithCorrectValues() { var expected = OrganisationBuilder.Create(1).WithAddress(AddressBuilder.Create().Build()).Build(); var calledBack = false; var mockOrganisationRepository = new Mock <IOrganisationRepository>(); mockOrganisationRepository.Setup(r => r.CreateOrganisationAsync(It.IsAny <Organisation>())) .Callback((Organisation actual) => { actual.Should().BeEquivalentTo(expected, c => c .Excluding(o => o.OrganisationId) .Using <DateTime>(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation, 1000)) .WhenTypeIs <DateTime>()); actual.OrganisationId.Should().NotBeEmpty(); calledBack = true; }); var service = new CreateOrganisationService(mockOrganisationRepository.Object, SetUpValidator(true)); await service.CreateAsync(SetUpRequest( expected.Name, expected.OdsCode, expected.PrimaryRoleId, expected.CatalogueAgreementSigned, expected.Address)); calledBack.Should().BeTrue(); }
public void FromModel_NullAddressModel_ThrowsException() { Address address = AddressBuilder .Create() .Build(); Assert.Throws <ArgumentNullException>(() => { address.FromModel(null); }); }
public static async Task GetAllAsync_ListOfOrganisationsExist_ReturnsTheOrganisations() { Address address = AddressBuilder.Create().WithLine1("2 City Close").Build(); var org1 = OrganisationBuilder.Create(1).WithCatalogueAgreementSigned(false).WithAddress(Address1).Build(); var org2 = OrganisationBuilder.Create(2).WithAddress(address).Build(); var org3 = OrganisationBuilder.Create(3).Build(); var controller = OrganisationControllerBuilder .Create() .WithListOrganisation(new List <Organisation> { org1, org2, org3 }) .Build(); var result = await controller.GetAllAsync(); result.Should().BeOfType <OkObjectResult>(); result.Should().NotBe(null); result.As <OkObjectResult>().Value.Should().BeOfType <GetAllOrganisationsModel>(); var organisationResult = (GetAllOrganisationsModel)result.As <OkObjectResult>().Value; organisationResult.Organisations.Count().Should().Be(3); var organisationList = organisationResult.Organisations.ToList(); organisationList[0].Should().BeEquivalentTo( org1, config => config .Excluding(o => o.LastUpdated) .Excluding(o => o.RelatedOrganisations) .Excluding(o => o.ParentRelatedOrganisations)); organisationList[1].Should().BeEquivalentTo( org2, config => config .Excluding(o => o.LastUpdated) .Excluding(o => o.RelatedOrganisations) .Excluding(o => o.ParentRelatedOrganisations)); organisationList[2].Should().BeEquivalentTo( org3, config => config .Excluding(o => o.LastUpdated) .Excluding(o => o.RelatedOrganisations) .Excluding(o => o.ParentRelatedOrganisations)); }
public Domain.ImportNotification.Address Map(Address source) { var builder = addressBuilder.Create(source.AddressLine1, source.TownOrCity, source.CountryId.Value); if (!string.IsNullOrWhiteSpace(source.PostalCode)) { builder = builder.WithPostalCode(source.PostalCode); } if (!string.IsNullOrWhiteSpace(source.AddressLine2)) { builder = builder.WithAddressLine2(source.AddressLine2); } return(builder.ToAddress()); }
public void FromModel_AddressModel_UpdatesAddress() { Address address = AddressBuilder .Create() .Build(); AddressModel inputAddressModel = new AddressModel { Line1 = Guid.NewGuid().ToString(), Line2 = Guid.NewGuid().ToString(), Line3 = Guid.NewGuid().ToString(), Line4 = Guid.NewGuid().ToString(), Line5 = Guid.NewGuid().ToString(), Town = Guid.NewGuid().ToString(), County = Guid.NewGuid().ToString(), Postcode = Guid.NewGuid().ToString(), Country = Guid.NewGuid().ToString() }; var actualAddress = address.FromModel(inputAddressModel); actualAddress.Should().BeEquivalentTo(inputAddressModel); }
/// <summary> /// Create a new <see cref="AddressBuilder"/> /// </summary> /// <returns>A <see cref="AddressBuilder"/></returns> public IAddressBuilder Create() => AddressBuilder.Create();