コード例 #1
0
        private async Task <Tuple <Guid, Guid> > CreateWeeeReusedSite(AatfSiteDataAccess dataAccess, AatfAddress aatfAddress, DatabaseWrapper database)
        {
            var organisation = ObligatedWeeeIntegrationCommon.CreateOrganisation();
            var scheme       = ObligatedWeeeIntegrationCommon.CreateScheme(organisation);
            var aatf         = ObligatedWeeeIntegrationCommon.CreateAatf(database, organisation);
            var @return      = ObligatedWeeeIntegrationCommon.CreateReturn(organisation, database.Model.AspNetUsers.First().Id);

            database.WeeeContext.Organisations.Add(organisation);
            database.WeeeContext.Schemes.Add(scheme);
            database.WeeeContext.Aatfs.Add(aatf);
            database.WeeeContext.Returns.Add(@return);

            await database.WeeeContext.SaveChangesAsync();

            var weeeReused = new WeeeReused(aatf.Id, @return.Id);

            database.WeeeContext.WeeeReused.Add(weeeReused);
            foreach (var category in Enum.GetValues(typeof(WeeeCategory)).Cast <WeeeCategory>())
            {
                database.WeeeContext.WeeeReusedAmount.Add(new WeeeReusedAmount(weeeReused, (int)category, (int)category, (int)category + 1));
            }

            await database.WeeeContext.SaveChangesAsync();

            var weeeReusedSite = new WeeeReusedSite(weeeReused, aatfAddress);

            await dataAccess.Submit(weeeReusedSite);

            return(Tuple.Create(@return.Id, aatf.Id));
        }
コード例 #2
0
        public void Submit_GivenReusedSiteData_ValuesShouldBeAddedToContext()
        {
            var aatfAddress = new AatfAddress(
                "Name",
                "Address",
                A.Dummy <string>(),
                "TownOrCity",
                A.Dummy <string>(),
                A.Dummy <string>(),
                A.Dummy <Country>());
            var weeeReused     = new WeeeReused(aatfId, A.Dummy <Guid>());
            var weeeReusedSite = new WeeeReusedSite(weeeReused, aatfAddress);

            var weeeReusedSiteDbSet = dbContextHelper.GetAsyncEnabledDbSet(new List <WeeeReusedSite>());

            A.CallTo(() => context.WeeeReusedSite).Returns(weeeReusedSiteDbSet);

            dataAccess.Submit(weeeReusedSite);

            context.WeeeReusedSite.Should().AllBeEquivalentTo(weeeReusedSite);
        }
コード例 #3
0
        private static async Task CreateWeeeReusedAmounts(
            ObligatedReusedDataAccess obligatedReusedDataAccess,
            AatfSiteDataAccess aatfSiteDataAccess,
            Return @return,
            Aatf aatf,
            AatfAddress address)
        {
            var weeeReused = new WeeeReused(aatf.Id, @return.Id);

            var weeeReusedAmount = new List <WeeeReusedAmount>();

            foreach (var category in Enum.GetValues(typeof(WeeeCategory)).Cast <WeeeCategory>())
            {
                weeeReusedAmount.Add(new WeeeReusedAmount(weeeReused, (int)category, (int)category, (int)category + 1));
            }

            var weeeReusedSite = new WeeeReusedSite(weeeReused, address);

            await obligatedReusedDataAccess.Submit(weeeReusedAmount);

            await aatfSiteDataAccess.Submit(weeeReusedSite);
        }