public async Task CopyOrganisationAddressIntoRegisteredOfficeHandler_CopiedOrganisationAddressToRegisteredOffice()
        {
            var organisations = MakeOrganisation();
            var addresses     = MakeAddress();

            var context = A.Fake <WeeeContext>();

            A.CallTo(() => context.Organisations).Returns(organisations);
            A.CallTo(() => context.Addresses).Returns(addresses);

            var handler = new CopyOrganisationAddressIntoRegisteredOfficeHandler(permissiveAuthorization, context);

            var organisationId =
                await
                handler.HandleAsync(
                    new CopyOrganisationAddressIntoRegisteredOffice(organisations.FirstOrDefault().Id, addresses.FirstOrDefault().Id));

            var organisationInfo = organisations.FirstOrDefault();
            var addressInfo      = addresses.FirstOrDefault();

            Assert.NotNull(organisationInfo);
            Assert.NotNull(organisationId);
            Assert.Equal(organisationInfo.BusinessAddress.Address1, addressInfo.Address1);
            Assert.Equal(organisationInfo.BusinessAddress.Address2, addressInfo.Address2);
            Assert.Equal(organisationInfo.BusinessAddress.TownOrCity, addressInfo.TownOrCity);
            Assert.Equal(organisationInfo.BusinessAddress.CountyOrRegion, addressInfo.CountyOrRegion);
            Assert.Equal(organisationInfo.BusinessAddress.Postcode, addressInfo.Postcode);
            Assert.Equal(organisationInfo.BusinessAddress.Country, addressInfo.Country);
            Assert.Equal(organisationInfo.BusinessAddress.Telephone, addressInfo.Telephone);
            Assert.Equal(organisationInfo.BusinessAddress.Email, addressInfo.Email);
        }
        public async Task CopyOrganisationAddressIntoRegisteredOfficeHandler_NotOrganisationUser_ThrowsSecurityException()
        {
            var handler = new CopyOrganisationAddressIntoRegisteredOfficeHandler(denyingAuthorization, A.Dummy <WeeeContext>());
            var message = new CopyOrganisationAddressIntoRegisteredOffice(Guid.NewGuid(), Guid.NewGuid());

            await Assert.ThrowsAsync <SecurityException>(async() => await handler.HandleAsync(message));
        }
        public async Task CopyOrganisationAddressIntoRegisteredOfficeHandler_NoSuchOrganisation_ThrowsArgumentException()
        {
            var organisationId = Guid.NewGuid();
            var address        = MakeAddress();

            var context = A.Fake <WeeeContext>();

            A.CallTo(() => context.Organisations).Returns(dbHelper.GetAsyncEnabledDbSet(new List <Organisation>()));
            A.CallTo(() => context.Addresses).Returns(dbHelper.GetAsyncEnabledDbSet(address));

            var handler = new CopyOrganisationAddressIntoRegisteredOfficeHandler(permissiveAuthorization, context);
            var message = new CopyOrganisationAddressIntoRegisteredOffice(organisationId, address.First().Id);

            var exception = await Assert.ThrowsAsync <ArgumentException>(async() => await handler.HandleAsync(message));

            Assert.True(exception.Message.Contains(organisationId.ToString()));
            Assert.True(exception.Message.ToUpperInvariant().Contains("COULD NOT FIND"));
            Assert.True(exception.Message.ToUpperInvariant().Contains("ORGANISATION"));
        }