コード例 #1
0
        private static void AssertUpdated(WeeeContext context, Guid aatfId, AatfContactData newContact, Domain.Country newCountry)
        {
            var updatedContact = context.Aatfs.First(a => a.Id == aatfId).Contact;

            updatedContact.Should().NotBeNull();
            updatedContact.FirstName.Should().NotBeNullOrEmpty();
            updatedContact.FirstName.Should().Be(newContact.FirstName);
            updatedContact.LastName.Should().NotBeNullOrEmpty();
            updatedContact.LastName.Should().Be(newContact.LastName);
            updatedContact.Position.Should().NotBeNullOrEmpty();
            updatedContact.Position.Should().Be(newContact.Position);
            updatedContact.Address1.Should().NotBeNullOrEmpty();
            updatedContact.Address1.Should().Be(newContact.AddressData.Address1);
            updatedContact.Address2.Should().Be(newContact.AddressData.Address2);
            updatedContact.TownOrCity.Should().NotBeNullOrEmpty();
            updatedContact.TownOrCity.Should().Be(newContact.AddressData.TownOrCity);
            updatedContact.CountyOrRegion.Should().Be(newContact.AddressData.CountyOrRegion);
            updatedContact.Postcode.Should().Be(newContact.AddressData.Postcode);
            updatedContact.CountryId.Should().NotBeEmpty();
            updatedContact.CountryId.Should().Be(newCountry.Id);
            updatedContact.Telephone.Should().NotBeNullOrEmpty();
            updatedContact.Telephone.Should().Be(newContact.Telephone);
            updatedContact.Email.Should().NotBeNullOrEmpty();
            updatedContact.Email.Should().Be(newContact.Email);
        }
コード例 #2
0
        public void UpdateContact_GivenNewAddressData_SaveChangesAsyncShouldBeCalled()
        {
            var oldSite = A.Fake <AatfContact>();
            var newSite = new AatfContactData()
            {
                AddressData = new AatfContactAddressData()
            };
            var country = A.Fake <Country>();

            dataAccess.UpdateContact(oldSite, newSite, country);

            A.CallTo(() => oldSite.UpdateDetails(
                         newSite.FirstName,
                         newSite.LastName,
                         newSite.Position,
                         newSite.AddressData.Address1,
                         newSite.AddressData.Address2,
                         newSite.AddressData.TownOrCity,
                         newSite.AddressData.CountyOrRegion,
                         newSite.AddressData.Postcode,
                         country,
                         newSite.Telephone,
                         newSite.Email)).MustHaveHappened(Repeated.Exactly.Once)
            .Then(A.CallTo(() => context.SaveChangesAsync()).MustHaveHappened(Repeated.Exactly.Once));
        }
コード例 #3
0
        public async void UpdateDetails_GivenDetailsToUpdate_ContextShouldContainUpdatedDetails()
        {
            using (var database = new DatabaseWrapper())
            {
                var context = database.WeeeContext;

                var country = await context.Countries.SingleAsync(c => c.Name == "France");

                var aatfAddress = new AatfContact("FirstName", "LastName", "Position", "Address1", "Address2", "Town", "County", "PO12ST34", country, "Telephone", "Email");

                var dataAccess = new AatfDataAccess(context, new GenericDataAccess(database.WeeeContext), quarterWindowFactory);

                var aatfId = await CreateContact(database, aatfAddress);

                var oldContact = context.Aatfs.First(a => a.Id == aatfId).Contact;

                var newAddressData = new AatfContactAddressData(null, "Address11", "Address21", "Town1", "County1", "PO12ST341", country.Id, country.Name);
                var newContact     = new AatfContactData(A.Dummy <Guid>(), "FirstName1", "LastName1", "Position1", newAddressData, "Telephone1", "Email1");
                var newCountry     = await context.Countries.SingleAsync(c => c.Name == "Germany");

                await dataAccess.UpdateContact(oldContact, newContact, newCountry);

                AssertUpdated(context, aatfId, newContact, newCountry);
            }
        }
コード例 #4
0
        public void Map_GivenSource_ContactDataIsMapped()
        {
            Guid   countryId   = Guid.NewGuid();
            string countryName = "Country";

            AatfContactAddressData addressData = new AatfContactAddressData("Name", "Address1", "Address2", "Town", "County", "Postcode", countryId, countryName);

            var aatfContact = new AatfContactData(
                Guid.NewGuid(),
                "First Name",
                "Last Name",
                "Position",
                addressData,
                "01234 567890",
                "*****@*****.**");

            var result = map.Map(aatfContact);

            result.FirstName.Should().Be("First Name");
            result.LastName.Should().Be("Last Name");
            result.Position.Should().Be("Position");
            result.Address1.Should().Be("Address1");
            result.Address2.Should().Be("Address2");
            result.TownOrCity.Should().Be("Town");
            result.CountyOrRegion.Should().Be("County");
            result.Postcode.Should().Be("Postcode");
            result.CountryId.Should().Be(countryId);
            result.Telephone.Should().Be("01234 567890");
            result.Email.Should().Be("*****@*****.**");
        }
コード例 #5
0
        public async void HandleAsync_GivenAatfId_MappedObjectShouldBeReturned()
        {
            var aatfContactData = new AatfContactData();

            A.CallTo(() => mapper.Map(A <AatfContact> ._)).Returns(aatfContactData);

            var result = await handler.HandleAsync(A.Dummy <GetAatfContact>());

            result.Should().Be(aatfContactData);
        }
コード例 #6
0
        public Task UpdateContact(AatfContact oldDetails, AatfContactData newDetails, Country country)
        {
            oldDetails.UpdateDetails(
                newDetails.FirstName,
                newDetails.LastName,
                newDetails.Position,
                newDetails.AddressData.Address1,
                newDetails.AddressData.Address2,
                newDetails.AddressData.TownOrCity,
                newDetails.AddressData.CountyOrRegion,
                newDetails.AddressData.Postcode,
                country,
                newDetails.Telephone,
                newDetails.Email);

            return(context.SaveChangesAsync());
        }
コード例 #7
0
 public AddFacilityViewModelBase()
 {
     ContactData     = new AatfContactData();
     SiteAddressData = new AatfAddressData();
 }
コード例 #8
0
 public EditAatfContact(Guid aatfId, AatfContactData contactData)
 {
     this.ContactData = contactData;
     this.AatfId      = aatfId;
 }