Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        private async Task <Guid> CreateContact(DatabaseWrapper database, AatfContact aatfAddress)
        {
            var organisation = ObligatedWeeeIntegrationCommon.CreateOrganisation();
            var scheme       = ObligatedWeeeIntegrationCommon.CreateScheme(organisation);

            var aatf = ObligatedWeeeIntegrationCommon.CreateAatf(database, organisation);

            database.WeeeContext.Organisations.Add(organisation);
            database.WeeeContext.Schemes.Add(scheme);
            database.WeeeContext.AatfContacts.Add(aatfAddress);
            database.WeeeContext.Aatfs.Add(aatf);

            await database.WeeeContext.SaveChangesAsync();

            return(aatf.Id);
        }