public async Task Submit_GivenSchemeAddedToContext_ChangesShouldBeSaved()
        {
            var items = A.Fake <List <ReturnScheme> >();

            await dataAccess.Submit(items);

            A.CallTo(() => context.ReturnScheme.AddRange(items)).MustHaveHappened().Then(
                A.CallTo(() => context.SaveChangesAsync()).MustHaveHappened(Repeated.Exactly.Once));
        }
        public async Task CanCreateReturnScheme()
        {
            using (var database = new DatabaseWrapper())
            {
                var context = database.WeeeContext;

                var          name        = "Test Name" + Guid.NewGuid();
                var          tradingName = "Test Trading Name" + Guid.NewGuid();
                const string crn         = "ABC12345";

                var organisation = Organisation.Organisation.CreateRegisteredCompany(name, crn, tradingName);

                context.Organisations.Add(organisation);
                await context.SaveChangesAsync();

                var scheme = new Scheme(organisation.Id);
                context.Schemes.Add(scheme);

                var quarter = new Quarter(2019, QuarterType.Q1);
                var @return = new Return(organisation, quarter, database.Model.AspNetUsers.First().Id, FacilityType.Aatf);

                context.Returns.Add(@return);
                await context.SaveChangesAsync();

                var dataAccess = new ReturnSchemeDataAccess(database.WeeeContext);

                var returnScheme = new ReturnScheme(scheme, @return);

                await dataAccess.Submit(new List <ReturnScheme> {
                    returnScheme
                });

                var returnSchemeReturned = context.ReturnScheme.First(o => o.Id == returnScheme.Id);
                returnSchemeReturned.Should().NotBeNull();
                returnSchemeReturned.ReturnId.Should().Be(@return.Id);
                returnSchemeReturned.SchemeId.Should().Be(scheme.Id);
            }
        }
Esempio n. 3
0
        private static async Task CreateWeeeReceivedAmounts(
            ObligatedReceivedDataAccess dataAccess,
            ReturnSchemeDataAccess returnSchemeDataAccess,
            Return @return,
            Aatf aatf,
            Scheme scheme)
        {
            var returnScheme = new ReturnScheme(scheme, @return);

            var weeeReceived = new WeeeReceived(scheme, aatf, @return);

            var weeeReceivedAmount = new List <WeeeReceivedAmount>();

            foreach (var category in Enum.GetValues(typeof(WeeeCategory)).Cast <WeeeCategory>())
            {
                weeeReceivedAmount.Add(new WeeeReceivedAmount(weeeReceived, (int)category, (int)category, (int)category + 1));
            }

            await returnSchemeDataAccess.Submit(new List <ReturnScheme> {
                returnScheme
            });

            await dataAccess.Submit(weeeReceivedAmount);
        }