public async Task Build_ExistingLatestSubmittedDataReturnVersion_WithAllExistingWeeeDeliveredAmounts_ReturnsDataReturnVersionWithExistingWeeeDeliveredReturnVersion()
        {
            var aatfDeliveryLocation = new AatfDeliveryLocation("ApprovalNumber", "FacilityName");

            var weeeDeliveredReturnVersion = new WeeeDeliveredReturnVersion();

            weeeDeliveredReturnVersion.AddWeeeDeliveredAmount(
                new WeeeDeliveredAmount(ObligationType.B2C, WeeeCategory.ConsumerEquipment, 100, aatfDeliveryLocation));

            var dataReturn        = new DataReturn(A.Dummy <Scheme>(), A.Dummy <Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, A.Dummy <WeeeCollectedReturnVersion>(),
                                                          weeeDeliveredReturnVersion, A.Dummy <EeeOutputReturnVersion>());

            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
            .Returns(dataReturn);

            A.CallTo(() => helper.DataAccess.GetOrAddAatfDeliveryLocation(A <string> ._, A <string> ._))
            .Returns(aatfDeliveryLocation);

            var builder = helper.Create();
            await builder.AddAatfDeliveredAmount("ApprovalNumber", "FacilityName", WeeeCategory.ConsumerEquipment, ObligationType.B2C, 100);

            var result = await builder.Build();

            Assert.Same(weeeDeliveredReturnVersion, result.DataReturnVersion.WeeeDeliveredReturnVersion);
        }
        public async Task Build_ExistingLatestSubmittedDataReturnVersion_WithAllExistingWeeeCollectedAmounts_ReturnsDataReturnVersionWithExistingWeeeCollectedReturnVersion()
        {
            var weeeCollectedReturnVersion = new WeeeCollectedReturnVersion();

            weeeCollectedReturnVersion.AddWeeeCollectedAmount(
                new WeeeCollectedAmount(WeeeCollectedAmountSourceType.Dcf, ObligationType.B2C, WeeeCategory.ConsumerEquipment, 100));

            var dataReturn        = new DataReturn(A.Dummy <Scheme>(), A.Dummy <Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, weeeCollectedReturnVersion,
                                                          A.Dummy <WeeeDeliveredReturnVersion>(), A.Dummy <EeeOutputReturnVersion>());

            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
            .Returns(dataReturn);

            var builder = helper.Create();
            await builder.AddWeeeCollectedAmount(WeeeCollectedAmountSourceType.Dcf, WeeeCategory.ConsumerEquipment, ObligationType.B2C, 100);

            var result = await builder.Build();

            Assert.Same(weeeCollectedReturnVersion, result.DataReturnVersion.WeeeCollectedReturnVersion);
        }
Ejemplo n.º 3
0
        public void CreateResults_ForDataReturnVersionWithNullWeeeCollectedDataReturnVersion_DoesNotIncludeWeeeCollectedDataReturnVersionItemsInResults()
        {
            // Arrange
            IWeeeAuthorization authorization = AuthorizationBuilder.CreateUserWithAllRights();

            GetUkWeeeCsvHandler handler = new GetUkWeeeCsvHandler(
                authorization,
                A.Dummy <IGetUkWeeeCsvDataAccess>(),
                A.Dummy <CsvWriterFactory>());

            var dataReturn        = new DataReturn(A.Fake <Domain.Scheme.Scheme>(), new Quarter(2016, QuarterType.Q1));
            var dataReturnVersion = new DataReturnVersion(dataReturn, null, A.Dummy <WeeeDeliveredReturnVersion>(), A.Dummy <EeeOutputReturnVersion>());

            dataReturn.SetCurrentVersion(dataReturnVersion);

            // Act
            var result = handler.CreateResults(new List <DataReturn> {
                dataReturn
            });

            // Assert
            Assert.All(result, r => Assert.Null(r.DcfQ1));
            Assert.All(result, r => Assert.Null(r.DistributorQ1));
            Assert.All(result, r => Assert.Null(r.FinalHolderQ1));
        }
        public async Task Build_ExistingLatestSubmittedDataReturnVersion_WithAllExistingEeeOutputAmounts_ReturnsDataReturnVersionWithExistingEeeOutputReturnVersion()
        {
            var registeredProducer = A.Fake <RegisteredProducer>();

            A.CallTo(() => registeredProducer.Equals(A <RegisteredProducer> ._))
            .Returns(true);

            var eeeOutputReturnVersion = new EeeOutputReturnVersion();

            eeeOutputReturnVersion.AddEeeOutputAmount(
                new EeeOutputAmount(ObligationType.B2C, WeeeCategory.ConsumerEquipment, 100, registeredProducer));

            var dataReturn        = new DataReturn(A.Dummy <Scheme>(), A.Dummy <Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, A.Dummy <WeeeCollectedReturnVersion>(),
                                                          A.Dummy <WeeeDeliveredReturnVersion>(), eeeOutputReturnVersion);

            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
            .Returns(dataReturn);

            A.CallTo(() => helper.DataAccess.GetRegisteredProducer(A <string> ._))
            .Returns(registeredProducer);

            var builder = helper.Create();
            await builder.AddEeeOutputAmount("PRN", "ProducerName", WeeeCategory.ConsumerEquipment, ObligationType.B2C, 100);

            var result = await builder.Build();

            Assert.Same(eeeOutputReturnVersion, result.DataReturnVersion.EeeOutputReturnVersion);
        }
        public async Task FetchResultsAsync_WithReturnDataForTowQuarters_ReturnsOneResultForEachQuarter()
        {
            using (Weee.Tests.Core.Model.DatabaseWrapper wrapper = new Weee.Tests.Core.Model.DatabaseWrapper())
            {
                // Arrange
                Organisation organisation = Organisation.CreateSoleTrader("Test Organisation");
                Scheme       scheme       = new Scheme(organisation);

                Quarter    quarter1     = new Quarter(2099, QuarterType.Q1);
                DataReturn dataReturnQ1 = new DataReturn(scheme, quarter1);

                DataReturnVersion versionQ1 = new DataReturnVersion(dataReturnQ1);

                WeeeCollectedAmount amountQ1 = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.Dcf,
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                versionQ1.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amountQ1);

                wrapper.WeeeContext.DataReturns.Add(dataReturnQ1);
                await wrapper.WeeeContext.SaveChangesAsync();

                dataReturnQ1.SetCurrentVersion(versionQ1);
                await wrapper.WeeeContext.SaveChangesAsync();

                Quarter    quarter2     = new Quarter(2099, QuarterType.Q2);
                DataReturn dataReturnQ2 = new DataReturn(scheme, quarter2);

                DataReturnVersion versionQ2 = new DataReturnVersion(dataReturnQ2);

                WeeeCollectedAmount amountQ2 = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.Dcf,
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                versionQ2.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amountQ2);

                wrapper.WeeeContext.DataReturns.Add(dataReturnQ2);
                await wrapper.WeeeContext.SaveChangesAsync();

                dataReturnQ2.SetCurrentVersion(versionQ2);
                await wrapper.WeeeContext.SaveChangesAsync();

                // Act
                FetchSummaryCsvDataAccess dataAccess = new FetchSummaryCsvDataAccess(wrapper.WeeeContext);

                List <DataReturnSummaryCsvData> results = await dataAccess.FetchResultsAsync(scheme.Id, 2099);

                // Assert
                Assert.NotNull(results);
                Assert.Equal(2, results.Count);

                Assert.Collection(results,
                                  r => Assert.Equal(1, r.Quarter),
                                  r => Assert.Equal(2, r.Quarter));
            }
        }
        public async Task Build_ExistingLatestSubmittedDataReturnVersion_WithSomeExistingEeeOutputAmounts_ReturnsDataReturnVersionWithExistingEeeOutputAmounts()
        {
            var registeredProducer1 = A.Fake <RegisteredProducer>();

            A.CallTo(() => registeredProducer1.ProducerRegistrationNumber)
            .Returns("Producer1");
            A.CallTo(() => registeredProducer1.Equals(A <RegisteredProducer> ._))
            .Returns(true);

            var registeredProducer2 = A.Fake <RegisteredProducer>();

            A.CallTo(() => registeredProducer2.ProducerRegistrationNumber)
            .Returns("Producer2");
            A.CallTo(() => registeredProducer2.Equals(A <RegisteredProducer> ._))
            .Returns(true);

            var eeeOutputAmount1 = new EeeOutputAmount(ObligationType.B2C, WeeeCategory.ConsumerEquipment, 100, registeredProducer1);
            var eeeOutputAmount2 = new EeeOutputAmount(ObligationType.B2C, WeeeCategory.MedicalDevices, 200, registeredProducer1);
            var eeeOutputAmount3 = new EeeOutputAmount(ObligationType.B2C, WeeeCategory.ToysLeisureAndSports, 100, registeredProducer2);
            var eeeOutputAmount4 = new EeeOutputAmount(ObligationType.B2C, WeeeCategory.ConsumerEquipment, 150, registeredProducer2);

            var eeeOutputReturnVersion = new EeeOutputReturnVersion();

            eeeOutputReturnVersion.AddEeeOutputAmount(eeeOutputAmount1);
            eeeOutputReturnVersion.AddEeeOutputAmount(eeeOutputAmount2);
            eeeOutputReturnVersion.AddEeeOutputAmount(eeeOutputAmount3);
            eeeOutputReturnVersion.AddEeeOutputAmount(eeeOutputAmount4);

            var dataReturn        = new DataReturn(A.Dummy <Scheme>(), A.Dummy <Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, A.Dummy <WeeeCollectedReturnVersion>(),
                                                          A.Dummy <WeeeDeliveredReturnVersion>(), eeeOutputReturnVersion);

            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
            .Returns(dataReturn);

            A.CallTo(() => helper.DataAccess.GetRegisteredProducer("Producer1"))
            .Returns(registeredProducer1);

            A.CallTo(() => helper.DataAccess.GetRegisteredProducer("Producer2"))
            .Returns(registeredProducer2);

            var builder = helper.Create();
            await builder.AddEeeOutputAmount("Producer1", "ProducerName", WeeeCategory.MedicalDevices, ObligationType.B2C, 200);

            await builder.AddEeeOutputAmount("Producer2", "ProducerName", WeeeCategory.ToysLeisureAndSports, ObligationType.B2C, 100);

            var result = await builder.Build();

            Assert.NotSame(eeeOutputReturnVersion, result.DataReturnVersion.EeeOutputReturnVersion);
            Assert.Collection(result.DataReturnVersion.EeeOutputReturnVersion.EeeOutputAmounts,
                              r1 => Assert.Same(eeeOutputAmount2, r1),
                              r2 => Assert.Same(eeeOutputAmount3, r2));
        }
        public async Task FetchResultsAsync_WithLargeHouseHoldAppliancesAmount_ReturnsNullForAllOtherCategories()
        {
            using (Weee.Tests.Core.Model.DatabaseWrapper wrapper = new Weee.Tests.Core.Model.DatabaseWrapper())
            {
                // Arrange
                Organisation organisation = Organisation.CreateSoleTrader("Test Organisation");
                Scheme       scheme       = new Scheme(organisation);

                Quarter    quarter    = new Quarter(2099, QuarterType.Q1);
                DataReturn dataReturn = new DataReturn(scheme, quarter);

                DataReturnVersion version = new DataReturnVersion(dataReturn);

                WeeeCollectedAmount amount1 = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.Dcf,
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                version.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amount1);

                wrapper.WeeeContext.DataReturns.Add(dataReturn);
                await wrapper.WeeeContext.SaveChangesAsync();

                dataReturn.SetCurrentVersion(version);
                await wrapper.WeeeContext.SaveChangesAsync();

                // Act
                FetchSummaryCsvDataAccess dataAccess = new FetchSummaryCsvDataAccess(wrapper.WeeeContext);

                List <DataReturnSummaryCsvData> results = await dataAccess.FetchResultsAsync(scheme.Id, 2099);

                // Assert
                Assert.NotNull(results);
                Assert.Equal(1, results.Count);

                DataReturnSummaryCsvData result = results[0];
                Assert.NotNull(result);

                Assert.NotNull(result.Category1);
                Assert.Null(result.Category2);
                Assert.Null(result.Category3);
                Assert.Null(result.Category4);
                Assert.Null(result.Category5);
                Assert.Null(result.Category6);
                Assert.Null(result.Category7);
                Assert.Null(result.Category8);
                Assert.Null(result.Category9);
                Assert.Null(result.Category10);
                Assert.Null(result.Category11);
                Assert.Null(result.Category12);
                Assert.Null(result.Category13);
                Assert.Null(result.Category14);
            }
        }
Ejemplo n.º 8
0
        public void SetCurrentDataReturnVersion_ThrowsArugmentNullException()
        {
            // Arrange
            Scheme scheme = new Scheme(Guid.NewGuid());
            Quarter quarter = new Quarter(2016, QuarterType.Q1);
            DataReturn dataReturn = new DataReturn(scheme, quarter);

            // Act
            Action action = () => dataReturn.SetCurrentVersion(null);

            // Assert
            Assert.Throws<ArgumentNullException>(action);
        }
Ejemplo n.º 9
0
        public void SetCurrentDataReturnVersion_ThrowsArugmentNullException()
        {
            // Arrange
            Scheme     scheme     = new Scheme(Guid.NewGuid());
            Quarter    quarter    = new Quarter(2016, QuarterType.Q1);
            DataReturn dataReturn = new DataReturn(scheme, quarter);

            // Act
            Action action = () => dataReturn.SetCurrentVersion(null);

            // Assert
            Assert.Throws <ArgumentNullException>(action);
        }
        public async Task FetchResultsAsync_WithSeveralOutputAmounts_ReturnsSumOfAmounts()
        {
            using (Weee.Tests.Core.Model.DatabaseWrapper wrapper = new Weee.Tests.Core.Model.DatabaseWrapper())
            {
                // Arrange
                Organisation organisation = Organisation.CreateSoleTrader("Test Organisation");
                Scheme       scheme       = new Scheme(organisation);

                RegisteredProducer registeredProducer1 = new RegisteredProducer("WEE/AA1111AA", 2099, scheme);
                RegisteredProducer registeredProducer2 = new RegisteredProducer("WEE/BB2222BB", 2099, scheme);

                Quarter    quarter    = new Quarter(2099, QuarterType.Q1);
                DataReturn dataReturn = new DataReturn(scheme, quarter);

                DataReturnVersion version = new DataReturnVersion(dataReturn);

                EeeOutputAmount amount1 = new EeeOutputAmount(
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    100,
                    registeredProducer1);
                version.EeeOutputReturnVersion.AddEeeOutputAmount(amount1);

                EeeOutputAmount amount2 = new EeeOutputAmount(
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    200,
                    registeredProducer2);
                version.EeeOutputReturnVersion.AddEeeOutputAmount(amount2);

                wrapper.WeeeContext.DataReturns.Add(dataReturn);
                await wrapper.WeeeContext.SaveChangesAsync();

                dataReturn.SetCurrentVersion(version);
                await wrapper.WeeeContext.SaveChangesAsync();

                // Act
                FetchSummaryCsvDataAccess dataAccess = new FetchSummaryCsvDataAccess(wrapper.WeeeContext);

                List <DataReturnSummaryCsvData> results = await dataAccess.FetchResultsAsync(scheme.Id, 2099);

                // Assert
                Assert.NotNull(results);
                Assert.Equal(1, results.Count);

                DataReturnSummaryCsvData result = results[0];
                Assert.NotNull(result);

                Assert.Equal(300, result.Category1);
            }
        }
Ejemplo n.º 11
0
        public void SetCurrentDataReturnVersion_ThrowInvalidOperationException()
        {
            // Arrange
            Scheme            scheme     = new Scheme(Guid.NewGuid());
            Quarter           quarter    = new Quarter(2016, QuarterType.Q1);
            DataReturn        dataReturn = new DataReturn(scheme, quarter);
            DataReturnVersion version    = new DataReturnVersion(new DataReturn(scheme, quarter));

            // Act
            Action action = () => dataReturn.SetCurrentVersion(version);

            // Assert
            Assert.Throws <InvalidOperationException>(action);
        }
Ejemplo n.º 12
0
        public void SetCurrentDataReturnVersion_ThrowInvalidOperationException()
        {
            // Arrange
            Scheme scheme = new Scheme(Guid.NewGuid());
            Quarter quarter = new Quarter(2016, QuarterType.Q1);
            DataReturn dataReturn = new DataReturn(scheme, quarter);
            DataReturnVersion version = new DataReturnVersion(new DataReturn(scheme, quarter));

            // Act
            Action action = () => dataReturn.SetCurrentVersion(version);

            // Assert
            Assert.Throws<InvalidOperationException>(action);
        }
Ejemplo n.º 13
0
        public void CreateResults_WithSeveralDcfCollectedAmountsInDifferentQuarters_PopulatesDcfTotalWithSum()
        {
            // Arrange
            DataReturn dataReturn1 = new DataReturn(A.Dummy <Domain.Scheme.Scheme>(), new Quarter(2016, QuarterType.Q2));

            DataReturnVersion dataReturnVersion1 = new DataReturnVersion(dataReturn1);

            WeeeCollectedAmount weeeCollectedAmount1 = new WeeeCollectedAmount(
                WeeeCollectedAmountSourceType.Dcf,
                DomainObligationType.B2C,
                WeeeCategory.LargeHouseholdAppliances,
                100);

            dataReturnVersion1.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(weeeCollectedAmount1);

            dataReturn1.SetCurrentVersion(dataReturnVersion1);

            DataReturn dataReturn2 = new DataReturn(A.Dummy <Domain.Scheme.Scheme>(), new Quarter(2016, QuarterType.Q4));

            DataReturnVersion dataReturnVersion2 = new DataReturnVersion(dataReturn2);

            WeeeCollectedAmount weeeCollectedAmount2 = new WeeeCollectedAmount(
                WeeeCollectedAmountSourceType.Dcf,
                DomainObligationType.B2C,
                WeeeCategory.LargeHouseholdAppliances,
                200);

            dataReturnVersion2.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(weeeCollectedAmount2);

            dataReturn2.SetCurrentVersion(dataReturnVersion2);

            GetUkWeeeCsvHandler handler = new GetUkWeeeCsvHandler(
                A.Dummy <IWeeeAuthorization>(),
                A.Dummy <IGetUkWeeeCsvDataAccess>(),
                A.Dummy <CsvWriterFactory>());

            // Act
            IEnumerable <GetUkWeeeCsvHandler.CsvResult> results = handler.CreateResults(new List <DataReturn>()
            {
                dataReturn1, dataReturn2
            });

            // Assert
            GetUkWeeeCsvHandler.CsvResult result = results
                                                   .Single(r => r.Category == WeeeCategory.LargeHouseholdAppliances && r.ObligationType == DomainObligationType.B2C);
            Assert.NotNull(result);

            Assert.Equal(300, result.DcfTotal);
        }
        public async Task FetchResultsAsync_WithQ1ReturnDataWithDeliveredToAeB2CAmount_ReturnsOneResultForQ1Type1Source1B2C()
        {
            using (Weee.Tests.Core.Model.DatabaseWrapper wrapper = new Weee.Tests.Core.Model.DatabaseWrapper())
            {
                // Arrange
                Organisation organisation = Organisation.CreateSoleTrader("Test Organisation");
                Scheme       scheme       = new Scheme(organisation);

                Quarter    quarter    = new Quarter(2099, QuarterType.Q1);
                DataReturn dataReturn = new DataReturn(scheme, quarter);

                DataReturnVersion version = new DataReturnVersion(dataReturn);

                WeeeDeliveredAmount amount1 = new WeeeDeliveredAmount(
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    new AeDeliveryLocation("WEE/AA1111AA/AE", string.Empty));
                version.WeeeDeliveredReturnVersion.AddWeeeDeliveredAmount(amount1);

                wrapper.WeeeContext.DataReturns.Add(dataReturn);
                await wrapper.WeeeContext.SaveChangesAsync();

                dataReturn.SetCurrentVersion(version);
                await wrapper.WeeeContext.SaveChangesAsync();

                // Act
                FetchSummaryCsvDataAccess dataAccess = new FetchSummaryCsvDataAccess(wrapper.WeeeContext);

                List <DataReturnSummaryCsvData> results = await dataAccess.FetchResultsAsync(scheme.Id, 2099);

                // Assert
                Assert.NotNull(results);
                Assert.Equal(1, results.Count);

                DataReturnSummaryCsvData result = results[0];
                Assert.NotNull(result);

                Assert.Equal(1, result.Quarter);
                Assert.Equal(1, result.Type);
                Assert.Equal(1, result.Source);
                Assert.Equal("B2C", result.ObligationType);
            }
        }
        public async Task Build_ExistingLatestDataReturnVersion_WithSomeExistingWeeeDeliveredAmounts_ReturnsDataReturnVersionWithExistingWeeeDeliveredAmounts()
        {
            var weeeDeliveredAmount1 = new WeeeDeliveredAmount(ObligationType.B2C, WeeeCategory.ConsumerEquipment, 100, new AatfDeliveryLocation("ApprovalNumber", "FacilityName"));
            var weeeDeliveredAmount2 = new WeeeDeliveredAmount(ObligationType.B2C, WeeeCategory.ITAndTelecommsEquipment, 200, new AatfDeliveryLocation("ApprovalNumber", "FacilityName"));
            var weeeDeliveredAmount3 = new WeeeDeliveredAmount(ObligationType.B2C, WeeeCategory.DisplayEquipment, 100, new AeDeliveryLocation("ApprovalNumber", "FacilityName"));
            var weeeDeliveredAmount4 = new WeeeDeliveredAmount(ObligationType.B2C, WeeeCategory.LargeHouseholdAppliances, 300, new AeDeliveryLocation("ApprovalNumber", "OperatorName"));

            var weeeDeliveredReturnVersion = new WeeeDeliveredReturnVersion();

            weeeDeliveredReturnVersion.AddWeeeDeliveredAmount(weeeDeliveredAmount1);
            weeeDeliveredReturnVersion.AddWeeeDeliveredAmount(weeeDeliveredAmount2);
            weeeDeliveredReturnVersion.AddWeeeDeliveredAmount(weeeDeliveredAmount3);
            weeeDeliveredReturnVersion.AddWeeeDeliveredAmount(weeeDeliveredAmount4);

            var dataReturn        = new DataReturn(A.Dummy <Scheme>(), A.Dummy <Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, A.Dummy <WeeeCollectedReturnVersion>(),
                                                          weeeDeliveredReturnVersion, A.Dummy <EeeOutputReturnVersion>());

            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
            .Returns(dataReturn);

            A.CallTo(() => helper.DataAccess.GetOrAddAatfDeliveryLocation(A <string> ._, A <string> ._))
            .Returns(new AatfDeliveryLocation("ApprovalNumber", "FacilityName"));
            A.CallTo(() => helper.DataAccess.GetOrAddAeDeliveryLocation(A <string> ._, A <string> ._))
            .Returns(new AeDeliveryLocation("ApprovalNumber", "OperatorName"));

            var builder = helper.Create();
            await builder.AddAatfDeliveredAmount("ApprovalNumber", "FacilityName", WeeeCategory.ConsumerEquipment, ObligationType.B2C, 100);

            await builder.AddAeDeliveredAmount("ApprovalNumber", "OperatorName", WeeeCategory.LargeHouseholdAppliances, ObligationType.B2C, 300);

            var result = await builder.Build();

            Assert.NotSame(weeeDeliveredReturnVersion, result.DataReturnVersion.WeeeDeliveredReturnVersion);
            Assert.Collection(result.DataReturnVersion.WeeeDeliveredReturnVersion.WeeeDeliveredAmounts,
                              r1 => Assert.Same(weeeDeliveredAmount1, r1),
                              r2 => Assert.Same(weeeDeliveredAmount4, r2));
        }
        public async Task Build_ExistingLatestSubmittedDataReturnVersion_DoesNotContainReturnData_WithNoDataForNewReturn_ReturnsNullReturnVersions()
        {
            var dataReturn        = new DataReturn(A.Dummy <Scheme>(), A.Dummy <Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, null, null, null);

            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
            .Returns(dataReturn);

            var builder = helper.Create();

            var result = await builder.Build();

            Assert.Null(result.DataReturnVersion.WeeeCollectedReturnVersion);
            Assert.Null(result.DataReturnVersion.WeeeDeliveredReturnVersion);
            Assert.Null(result.DataReturnVersion.EeeOutputReturnVersion);
        }
        public async Task Build_ExistingLatestSubmittedDataReturnVersion_WithNoExistingWeeeDeliveredReturnVersion_ReturnsDataReturnVersionWithNewWeeeDeliveredReturnVersion()
        {
            var dataReturn        = new DataReturn(A.Dummy <Scheme>(), A.Dummy <Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, A.Dummy <WeeeCollectedReturnVersion>(),
                                                          null, A.Dummy <EeeOutputReturnVersion>());

            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
            .Returns(dataReturn);

            var builder = helper.Create();
            await builder.AddAatfDeliveredAmount("ApprovalNumber", "FacilityName", WeeeCategory.ConsumerEquipment, ObligationType.B2C, 100);

            var result = await builder.Build();

            Assert.NotNull(result.DataReturnVersion.WeeeDeliveredReturnVersion);
            Assert.Equal(1, result.DataReturnVersion.WeeeDeliveredReturnVersion.WeeeDeliveredAmounts.Count);
        }
Ejemplo n.º 18
0
        public void CreateResults_WithQ1DeliveredAmountOfZero_PopulatesDeliveredQ1AndDeliveredTotalWithZero()
        {
            // Arrange
            DataReturn dataReturn = new DataReturn(A.Dummy <Domain.Scheme.Scheme>(), new Quarter(2016, QuarterType.Q1));

            DataReturnVersion dataReturnVersion = new DataReturnVersion(dataReturn);

            WeeeDeliveredAmount weeeDeliveredAmount = new WeeeDeliveredAmount(
                DomainObligationType.B2C,
                WeeeCategory.LargeHouseholdAppliances,
                0,
                new AatfDeliveryLocation("WEE/AA1234AA/ATF", "Facility Name"));

            dataReturnVersion.WeeeDeliveredReturnVersion.AddWeeeDeliveredAmount(weeeDeliveredAmount);

            dataReturn.SetCurrentVersion(dataReturnVersion);

            GetUkWeeeCsvHandler handler = new GetUkWeeeCsvHandler(
                A.Dummy <IWeeeAuthorization>(),
                A.Dummy <IGetUkWeeeCsvDataAccess>(),
                A.Dummy <CsvWriterFactory>());

            // Act
            IEnumerable <GetUkWeeeCsvHandler.CsvResult> results = handler.CreateResults(new List <DataReturn>()
            {
                dataReturn
            });

            // Assert
            GetUkWeeeCsvHandler.CsvResult result = results
                                                   .Single(r => r.Category == WeeeCategory.LargeHouseholdAppliances && r.ObligationType == DomainObligationType.B2C);
            Assert.NotNull(result);

            Assert.Equal(0, result.DeliveredQ1);
            Assert.Equal(null, result.DeliveredQ2);
            Assert.Equal(null, result.DeliveredQ3);
            Assert.Equal(null, result.DeliveredQ4);
            Assert.Equal(0, result.DeliveredTotal);
        }
Ejemplo n.º 19
0
        public void CreateResults_WithQ1FinalHolderCollectedAmountOfZero_PopulatesFinalHolderQ1AndFinalHolderTotalWithZero()
        {
            // Arrange
            DataReturn dataReturn = new DataReturn(A.Dummy <Domain.Scheme.Scheme>(), new Quarter(2016, QuarterType.Q1));

            DataReturnVersion dataReturnVersion = new DataReturnVersion(dataReturn);

            WeeeCollectedAmount weeeCollectedAmount = new WeeeCollectedAmount(
                WeeeCollectedAmountSourceType.FinalHolder,
                Domain.Obligation.ObligationType.B2C,
                WeeeCategory.LargeHouseholdAppliances,
                0);

            dataReturnVersion.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(weeeCollectedAmount);

            dataReturn.SetCurrentVersion(dataReturnVersion);

            GetUkWeeeCsvHandler handler = new GetUkWeeeCsvHandler(
                A.Dummy <IWeeeAuthorization>(),
                A.Dummy <IGetUkWeeeCsvDataAccess>(),
                A.Dummy <CsvWriterFactory>());

            // Act
            IEnumerable <GetUkWeeeCsvHandler.CsvResult> results = handler.CreateResults(new List <DataReturn>()
            {
                dataReturn
            });

            // Assert
            GetUkWeeeCsvHandler.CsvResult result = results
                                                   .Single(r => r.Category == WeeeCategory.LargeHouseholdAppliances && r.ObligationType == DomainObligationType.B2C);
            Assert.NotNull(result);

            Assert.Equal(0, result.FinalHolderQ1);
            Assert.Equal(null, result.FinalHolderQ2);
            Assert.Equal(null, result.FinalHolderQ3);
            Assert.Equal(null, result.FinalHolderQ4);
            Assert.Equal(0, result.FinalHolderTotal);
        }
        public async Task FetchResultsAsync_WithNoReturnDataForScheme_ReturnsEmptyList()
        {
            using (Weee.Tests.Core.Model.DatabaseWrapper wrapper = new Weee.Tests.Core.Model.DatabaseWrapper())
            {
                // Arrange
                Organisation organisation = Organisation.CreateSoleTrader("Test Organisation");
                Scheme       scheme1      = new Scheme(organisation);
                Scheme       scheme2      = new Scheme(organisation);

                Quarter    quarter    = new Quarter(2099, QuarterType.Q1);
                DataReturn dataReturn = new DataReturn(scheme1, quarter);

                DataReturnVersion version = new DataReturnVersion(dataReturn);

                WeeeCollectedAmount amount1 = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.Dcf,
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                version.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amount1);

                wrapper.WeeeContext.DataReturns.Add(dataReturn);
                await wrapper.WeeeContext.SaveChangesAsync();

                dataReturn.SetCurrentVersion(version);
                await wrapper.WeeeContext.SaveChangesAsync();

                // Act
                FetchSummaryCsvDataAccess dataAccess = new FetchSummaryCsvDataAccess(wrapper.WeeeContext);

                List <DataReturnSummaryCsvData> results = await dataAccess.FetchResultsAsync(scheme2.Id, 2099);

                // Assert
                Assert.NotNull(results);
                Assert.Empty(results);
            }
        }
        public async Task FetchResultsAsync_WithNoReturnDataForComplianceYear_ReturnsEmptyList()
        {
            using (Weee.Tests.Core.Model.DatabaseWrapper wrapper = new Weee.Tests.Core.Model.DatabaseWrapper())
            {
                // Arrange
                Organisation organisation = Organisation.CreateSoleTrader("Test Organisation");
                Scheme scheme = new Scheme(organisation);

                Quarter quarter = new Quarter(2059, QuarterType.Q1);
                DataReturn dataReturn = new DataReturn(scheme, quarter);

                DataReturnVersion version = new DataReturnVersion(dataReturn);

                WeeeCollectedAmount amount1 = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.Dcf,
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                version.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amount1);

                wrapper.WeeeContext.DataReturns.Add(dataReturn);
                await wrapper.WeeeContext.SaveChangesAsync();

                dataReturn.SetCurrentVersion(version);
                await wrapper.WeeeContext.SaveChangesAsync();

                // Act
                FetchSummaryCsvDataAccess dataAccess = new FetchSummaryCsvDataAccess(wrapper.WeeeContext);

                List<DataReturnSummaryCsvData> results = await dataAccess.FetchResultsAsync(scheme.Id, 2099);

                // Assert
                Assert.NotNull(results);
                Assert.Empty(results);
            }
        }
        public async Task Build_ExistingLatestDataReturnVersion_WithSomeExistingWeeeDeliveredAmounts_ReturnsDataReturnVersionWithExistingWeeeDeliveredAmounts()
        {
            var weeeDeliveredAmount1 = new WeeeDeliveredAmount(ObligationType.B2C, WeeeCategory.ConsumerEquipment, 100, new AatfDeliveryLocation("ApprovalNumber", "FacilityName"));
            var weeeDeliveredAmount2 = new WeeeDeliveredAmount(ObligationType.B2C, WeeeCategory.ITAndTelecommsEquipment, 200, new AatfDeliveryLocation("ApprovalNumber", "FacilityName"));
            var weeeDeliveredAmount3 = new WeeeDeliveredAmount(ObligationType.B2C, WeeeCategory.DisplayEquipment, 100, new AeDeliveryLocation("ApprovalNumber", "FacilityName"));
            var weeeDeliveredAmount4 = new WeeeDeliveredAmount(ObligationType.B2C, WeeeCategory.LargeHouseholdAppliances, 300, new AeDeliveryLocation("ApprovalNumber", "OperatorName"));

            var weeeDeliveredReturnVersion = new WeeeDeliveredReturnVersion();
            weeeDeliveredReturnVersion.AddWeeeDeliveredAmount(weeeDeliveredAmount1);
            weeeDeliveredReturnVersion.AddWeeeDeliveredAmount(weeeDeliveredAmount2);
            weeeDeliveredReturnVersion.AddWeeeDeliveredAmount(weeeDeliveredAmount3);
            weeeDeliveredReturnVersion.AddWeeeDeliveredAmount(weeeDeliveredAmount4);

            var dataReturn = new DataReturn(A.Dummy<Scheme>(), A.Dummy<Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, A.Dummy<WeeeCollectedReturnVersion>(),
                weeeDeliveredReturnVersion, A.Dummy<EeeOutputReturnVersion>());
            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
               .Returns(dataReturn);

            A.CallTo(() => helper.DataAccess.GetOrAddAatfDeliveryLocation(A<string>._, A<string>._))
                .Returns(new AatfDeliveryLocation("ApprovalNumber", "FacilityName"));
            A.CallTo(() => helper.DataAccess.GetOrAddAeDeliveryLocation(A<string>._, A<string>._))
                .Returns(new AeDeliveryLocation("ApprovalNumber", "OperatorName"));

            var builder = helper.Create();
            await builder.AddAatfDeliveredAmount("ApprovalNumber", "FacilityName", WeeeCategory.ConsumerEquipment, ObligationType.B2C, 100);
            await builder.AddAeDeliveredAmount("ApprovalNumber", "OperatorName", WeeeCategory.LargeHouseholdAppliances, ObligationType.B2C, 300);

            var result = await builder.Build();

            Assert.NotSame(weeeDeliveredReturnVersion, result.DataReturnVersion.WeeeDeliveredReturnVersion);
            Assert.Collection(result.DataReturnVersion.WeeeDeliveredReturnVersion.WeeeDeliveredAmounts,
                r1 => Assert.Same(weeeDeliveredAmount1, r1),
                r2 => Assert.Same(weeeDeliveredAmount4, r2));
        }
        public async Task Build_ExistingLatestSubmittedDataReturnVersion_WithSomeExistingWeeeCollectedAmounts_ReturnsDataReturnVersionWithExistingWeeeCollectedAmounts()
        {
            var weeeCollectedAmount1 = new WeeeCollectedAmount(WeeeCollectedAmountSourceType.Dcf, ObligationType.B2C, WeeeCategory.DisplayEquipment, 100);
            var weeeCollectedAmount2 = new WeeeCollectedAmount(WeeeCollectedAmountSourceType.Dcf, ObligationType.B2C, WeeeCategory.ConsumerEquipment, 100);
            var weeeCollectedAmount3 = new WeeeCollectedAmount(WeeeCollectedAmountSourceType.Distributor, ObligationType.B2C, WeeeCategory.ConsumerEquipment, 100);
            var weeeCollectedAmount4 = new WeeeCollectedAmount(WeeeCollectedAmountSourceType.FinalHolder, ObligationType.B2C, WeeeCategory.ConsumerEquipment, 100);

            var weeeCollectedReturnVersion = new WeeeCollectedReturnVersion();
            weeeCollectedReturnVersion.AddWeeeCollectedAmount(weeeCollectedAmount1);
            weeeCollectedReturnVersion.AddWeeeCollectedAmount(weeeCollectedAmount2);
            weeeCollectedReturnVersion.AddWeeeCollectedAmount(weeeCollectedAmount3);
            weeeCollectedReturnVersion.AddWeeeCollectedAmount(weeeCollectedAmount4);

            var dataReturn = new DataReturn(A.Dummy<Scheme>(), A.Dummy<Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, weeeCollectedReturnVersion,
                A.Dummy<WeeeDeliveredReturnVersion>(), A.Dummy<EeeOutputReturnVersion>());
            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
               .Returns(dataReturn);

            var builder = helper.Create();
            await builder.AddWeeeCollectedAmount(WeeeCollectedAmountSourceType.Dcf, WeeeCategory.ConsumerEquipment, ObligationType.B2C, 100);
            await builder.AddWeeeCollectedAmount(WeeeCollectedAmountSourceType.Distributor, WeeeCategory.ConsumerEquipment, ObligationType.B2C, 100);

            var result = await builder.Build();

            Assert.NotSame(weeeCollectedReturnVersion, result.DataReturnVersion.WeeeCollectedReturnVersion);
            Assert.Collection(result.DataReturnVersion.WeeeCollectedReturnVersion.WeeeCollectedAmounts,
                r1 => Assert.Same(weeeCollectedAmount2, r1),
                r2 => Assert.Same(weeeCollectedAmount3, r2));
        }
        public async Task Build_ExistingLatestSubmittedDataReturnVersion_WithAllExistingEeeOutputAmounts_ReturnsDataReturnVersionWithExistingEeeOutputReturnVersion()
        {
            var registeredProducer = A.Fake<RegisteredProducer>();
            A.CallTo(() => registeredProducer.Equals(A<RegisteredProducer>._))
                .Returns(true);

            var eeeOutputReturnVersion = new EeeOutputReturnVersion();
            eeeOutputReturnVersion.AddEeeOutputAmount(
                new EeeOutputAmount(ObligationType.B2C, WeeeCategory.ConsumerEquipment, 100, registeredProducer));

            var dataReturn = new DataReturn(A.Dummy<Scheme>(), A.Dummy<Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, A.Dummy<WeeeCollectedReturnVersion>(),
                A.Dummy<WeeeDeliveredReturnVersion>(), eeeOutputReturnVersion);
            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
               .Returns(dataReturn);

            A.CallTo(() => helper.DataAccess.GetRegisteredProducer(A<string>._))
                .Returns(registeredProducer);

            var builder = helper.Create();
            await builder.AddEeeOutputAmount("PRN", "ProducerName", WeeeCategory.ConsumerEquipment, ObligationType.B2C, 100);

            var result = await builder.Build();

            Assert.Same(eeeOutputReturnVersion, result.DataReturnVersion.EeeOutputReturnVersion);
        }
        public async Task Build_ExistingLatestSubmittedDataReturnVersion_WithAllExistingWeeeDeliveredAmounts_ReturnsDataReturnVersionWithExistingWeeeDeliveredReturnVersion()
        {
            var aatfDeliveryLocation = new AatfDeliveryLocation("ApprovalNumber", "FacilityName");

            var weeeDeliveredReturnVersion = new WeeeDeliveredReturnVersion();
            weeeDeliveredReturnVersion.AddWeeeDeliveredAmount(
                new WeeeDeliveredAmount(ObligationType.B2C, WeeeCategory.ConsumerEquipment, 100, aatfDeliveryLocation));

            var dataReturn = new DataReturn(A.Dummy<Scheme>(), A.Dummy<Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, A.Dummy<WeeeCollectedReturnVersion>(),
                weeeDeliveredReturnVersion, A.Dummy<EeeOutputReturnVersion>());
            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
               .Returns(dataReturn);

            A.CallTo(() => helper.DataAccess.GetOrAddAatfDeliveryLocation(A<string>._, A<string>._))
                .Returns(aatfDeliveryLocation);

            var builder = helper.Create();
            await builder.AddAatfDeliveredAmount("ApprovalNumber", "FacilityName", WeeeCategory.ConsumerEquipment, ObligationType.B2C, 100);

            var result = await builder.Build();

            Assert.Same(weeeDeliveredReturnVersion, result.DataReturnVersion.WeeeDeliveredReturnVersion);
        }
        public async Task Build_ExistingLatestSubmittedDataReturnVersion_WithNoExistingWeeeDeliveredReturnVersion_ReturnsDataReturnVersionWithNewWeeeDeliveredReturnVersion()
        {
            var dataReturn = new DataReturn(A.Dummy<Scheme>(), A.Dummy<Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, A.Dummy<WeeeCollectedReturnVersion>(),
                null, A.Dummy<EeeOutputReturnVersion>());
            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
                .Returns(dataReturn);

            var builder = helper.Create();
            await builder.AddAatfDeliveredAmount("ApprovalNumber", "FacilityName", WeeeCategory.ConsumerEquipment, ObligationType.B2C, 100);

            var result = await builder.Build();

            Assert.NotNull(result.DataReturnVersion.WeeeDeliveredReturnVersion);
            Assert.Equal(1, result.DataReturnVersion.WeeeDeliveredReturnVersion.WeeeDeliveredAmounts.Count);
        }
        public void CreateResults_WithQ1FinalHolderCollectedAmountOfZero_PopulatesFinalHolderQ1AndFinalHolderTotalWithZero()
        {
            // Arrange
            DataReturn dataReturn = new DataReturn(A.Dummy<Domain.Scheme.Scheme>(), new Quarter(2016, QuarterType.Q1));

            DataReturnVersion dataReturnVersion = new DataReturnVersion(dataReturn);

            WeeeCollectedAmount weeeCollectedAmount = new WeeeCollectedAmount(
                WeeeCollectedAmountSourceType.FinalHolder,
                Domain.Obligation.ObligationType.B2C,
                WeeeCategory.LargeHouseholdAppliances,
                0);

            dataReturnVersion.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(weeeCollectedAmount);

            dataReturn.SetCurrentVersion(dataReturnVersion);

            GetUkWeeeCsvHandler handler = new GetUkWeeeCsvHandler(
                A.Dummy<IWeeeAuthorization>(),
                A.Dummy<IGetUkWeeeCsvDataAccess>(),
                A.Dummy<CsvWriterFactory>());

            // Act
            IEnumerable<GetUkWeeeCsvHandler.CsvResult> results = handler.CreateResults(new List<DataReturn>() { dataReturn });

            // Assert
            GetUkWeeeCsvHandler.CsvResult result = results
                .Single(r => r.Category == WeeeCategory.LargeHouseholdAppliances && r.ObligationType == DomainObligationType.B2C);
            Assert.NotNull(result);

            Assert.Equal(0, result.FinalHolderQ1);
            Assert.Equal(null, result.FinalHolderQ2);
            Assert.Equal(null, result.FinalHolderQ3);
            Assert.Equal(null, result.FinalHolderQ4);
            Assert.Equal(0, result.FinalHolderTotal);
        }
        public async Task FetchResultsAsync_WithOneAmountOfEachTypeAndSourceAndObligationType_ReturnsResultForEachAmountWithCorrectOrdering()
        {
            using (Weee.Tests.Core.Model.DatabaseWrapper wrapper = new Weee.Tests.Core.Model.DatabaseWrapper())
            {
                // Arrange
                Organisation organisation = Organisation.CreateSoleTrader("Test Organisation");
                Scheme scheme = new Scheme(organisation);

                RegisteredProducer registeredProducer1 = new RegisteredProducer("WEE/AA9365AA", 2099, scheme);

                Quarter quarter = new Quarter(2099, QuarterType.Q1);
                DataReturn dataReturn = new DataReturn(scheme, quarter);

                DataReturnVersion version = new DataReturnVersion(dataReturn);

                WeeeCollectedAmount amountCollectedDcfB2C = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.Dcf,
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                version.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amountCollectedDcfB2C);

                WeeeCollectedAmount amountCollectedDistributor = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.Distributor,
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                version.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amountCollectedDistributor);

                WeeeCollectedAmount amountCollectedFinalHolder = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.FinalHolder,
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                version.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amountCollectedFinalHolder);

                WeeeDeliveredAmount amountDeliveredAatfB2C = new WeeeDeliveredAmount(
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    new AatfDeliveryLocation("WEE/AA6845AA/ATF", string.Empty));
                version.WeeeDeliveredReturnVersion.AddWeeeDeliveredAmount(amountDeliveredAatfB2C);

                WeeeDeliveredAmount amountDeliveredAeB2C = new WeeeDeliveredAmount(
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    new AeDeliveryLocation("WEE/AA2658AA/AE", string.Empty));
                version.WeeeDeliveredReturnVersion.AddWeeeDeliveredAmount(amountDeliveredAeB2C);

                EeeOutputAmount amountOutputB2C = new EeeOutputAmount(
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    registeredProducer1);
                version.EeeOutputReturnVersion.AddEeeOutputAmount(amountOutputB2C);

                WeeeCollectedAmount amountCollectedDcfB2B = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.Dcf,
                    ObligationType.B2B,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                version.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amountCollectedDcfB2B);

                WeeeDeliveredAmount amountDeliveredAatfB2B = new WeeeDeliveredAmount(
                    ObligationType.B2B,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    new AatfDeliveryLocation("WEE/AA7445AA/ATF", string.Empty));
                version.WeeeDeliveredReturnVersion.AddWeeeDeliveredAmount(amountDeliveredAatfB2B);

                WeeeDeliveredAmount amountDeliveredAeB2B = new WeeeDeliveredAmount(
                    ObligationType.B2B,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    new AeDeliveryLocation("WEE/AA3658AA/AE", string.Empty));
                version.WeeeDeliveredReturnVersion.AddWeeeDeliveredAmount(amountDeliveredAeB2B);

                EeeOutputAmount amountOutputB2B = new EeeOutputAmount(
                    ObligationType.B2B,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    registeredProducer1);
                version.EeeOutputReturnVersion.AddEeeOutputAmount(amountOutputB2B);

                wrapper.WeeeContext.DataReturns.Add(dataReturn);
                await wrapper.WeeeContext.SaveChangesAsync();

                dataReturn.SetCurrentVersion(version);
                await wrapper.WeeeContext.SaveChangesAsync();

                // Act
                FetchSummaryCsvDataAccess dataAccess = new FetchSummaryCsvDataAccess(wrapper.WeeeContext);

                List<DataReturnSummaryCsvData> results = await dataAccess.FetchResultsAsync(scheme.Id, 2099);

                // Assert
                Assert.NotNull(results);
                Assert.Equal(10, results.Count);
                Assert.Collection(results,
                    r => { Assert.Equal(0, r.Type); Assert.Equal(0, r.Source); Assert.Equal("B2C", r.ObligationType); },
                    r => { Assert.Equal(0, r.Type); Assert.Equal(0, r.Source); Assert.Equal("B2B", r.ObligationType); },
                    r => { Assert.Equal(0, r.Type); Assert.Equal(1, r.Source); Assert.Equal("B2C", r.ObligationType); },
                    r => { Assert.Equal(0, r.Type); Assert.Equal(2, r.Source); Assert.Equal("B2C", r.ObligationType); },
                    r => { Assert.Equal(1, r.Type); Assert.Equal(0, r.Source); Assert.Equal("B2C", r.ObligationType); },
                    r => { Assert.Equal(1, r.Type); Assert.Equal(0, r.Source); Assert.Equal("B2B", r.ObligationType); },
                    r => { Assert.Equal(1, r.Type); Assert.Equal(1, r.Source); Assert.Equal("B2C", r.ObligationType); },
                    r => { Assert.Equal(1, r.Type); Assert.Equal(1, r.Source); Assert.Equal("B2B", r.ObligationType); },
                    r => { Assert.Equal(2, r.Type); Assert.Equal(null, r.Source); Assert.Equal("B2C", r.ObligationType); },
                    r => { Assert.Equal(2, r.Type); Assert.Equal(null, r.Source); Assert.Equal("B2B", r.ObligationType); });
            }
        }
        public void CreateResults_WithSeveralDcfCollectedAmountsInDifferentQuarters_PopulatesDcfTotalWithSum()
        {
            // Arrange
            DataReturn dataReturn1 = new DataReturn(A.Dummy<Domain.Scheme.Scheme>(), new Quarter(2016, QuarterType.Q2));

            DataReturnVersion dataReturnVersion1 = new DataReturnVersion(dataReturn1);

            WeeeCollectedAmount weeeCollectedAmount1 = new WeeeCollectedAmount(
                WeeeCollectedAmountSourceType.Dcf,
                DomainObligationType.B2C,
                WeeeCategory.LargeHouseholdAppliances,
                100);

            dataReturnVersion1.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(weeeCollectedAmount1);

            dataReturn1.SetCurrentVersion(dataReturnVersion1);

            DataReturn dataReturn2 = new DataReturn(A.Dummy<Domain.Scheme.Scheme>(), new Quarter(2016, QuarterType.Q4));

            DataReturnVersion dataReturnVersion2 = new DataReturnVersion(dataReturn2);

            WeeeCollectedAmount weeeCollectedAmount2 = new WeeeCollectedAmount(
                WeeeCollectedAmountSourceType.Dcf,
                DomainObligationType.B2C,
                WeeeCategory.LargeHouseholdAppliances,
                200);

            dataReturnVersion2.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(weeeCollectedAmount2);

            dataReturn2.SetCurrentVersion(dataReturnVersion2);

            GetUkWeeeCsvHandler handler = new GetUkWeeeCsvHandler(
                A.Dummy<IWeeeAuthorization>(),
                A.Dummy<IGetUkWeeeCsvDataAccess>(),
                A.Dummy<CsvWriterFactory>());

            // Act
            IEnumerable<GetUkWeeeCsvHandler.CsvResult> results = handler.CreateResults(new List<DataReturn>() { dataReturn1, dataReturn2 });

            // Assert
            GetUkWeeeCsvHandler.CsvResult result = results
                .Single(r => r.Category == WeeeCategory.LargeHouseholdAppliances && r.ObligationType == DomainObligationType.B2C);
            Assert.NotNull(result);

            Assert.Equal(300, result.DcfTotal);
        }
        public void CreateResults_ForDataReturnVersionWithNullWeeeDeliveredDataReturnVersion_DoesNotIncludeWeeeDeliveredDataReturnVersionItemsInResults()
        {
            // Arrange
            IWeeeAuthorization authorization = AuthorizationBuilder.CreateUserWithAllRights();

            GetUkWeeeCsvHandler handler = new GetUkWeeeCsvHandler(
                authorization,
                A.Dummy<IGetUkWeeeCsvDataAccess>(),
                A.Dummy<CsvWriterFactory>());

            var dataReturn = new DataReturn(A.Fake<Domain.Scheme.Scheme>(), new Quarter(2016, QuarterType.Q1));
            var dataReturnVersion = new DataReturnVersion(dataReturn, A.Dummy<WeeeCollectedReturnVersion>(), null, A.Dummy<EeeOutputReturnVersion>());
            dataReturn.SetCurrentVersion(dataReturnVersion);

            // Act
            var result = handler.CreateResults(new List<DataReturn> { dataReturn });

            // Assert
            Assert.All(result, r => Assert.Null(r.DeliveredQ1));
        }
        public async Task FetchResultsAsync_WithQ1ReturnDataWithDeliveredToAeB2CAmount_ReturnsOneResultForQ1Type1Source1B2C()
        {
            using (Weee.Tests.Core.Model.DatabaseWrapper wrapper = new Weee.Tests.Core.Model.DatabaseWrapper())
            {
                // Arrange
                Organisation organisation = Organisation.CreateSoleTrader("Test Organisation");
                Scheme scheme = new Scheme(organisation);

                Quarter quarter = new Quarter(2099, QuarterType.Q1);
                DataReturn dataReturn = new DataReturn(scheme, quarter);

                DataReturnVersion version = new DataReturnVersion(dataReturn);

                WeeeDeliveredAmount amount1 = new WeeeDeliveredAmount(
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    new AeDeliveryLocation("WEE/AA1111AA/AE", string.Empty));
                version.WeeeDeliveredReturnVersion.AddWeeeDeliveredAmount(amount1);

                wrapper.WeeeContext.DataReturns.Add(dataReturn);
                await wrapper.WeeeContext.SaveChangesAsync();

                dataReturn.SetCurrentVersion(version);
                await wrapper.WeeeContext.SaveChangesAsync();

                // Act
                FetchSummaryCsvDataAccess dataAccess = new FetchSummaryCsvDataAccess(wrapper.WeeeContext);

                List<DataReturnSummaryCsvData> results = await dataAccess.FetchResultsAsync(scheme.Id, 2099);

                // Assert
                Assert.NotNull(results);
                Assert.Equal(1, results.Count);

                DataReturnSummaryCsvData result = results[0];
                Assert.NotNull(result);

                Assert.Equal(1, result.Quarter);
                Assert.Equal(1, result.Type);
                Assert.Equal(1, result.Source);
                Assert.Equal("B2C", result.ObligationType);
            }
        }
        public async Task FetchResultsAsync_WithLargeHouseHoldAppliancesAmount_ReturnsNullForAllOtherCategories()
        {
            using (Weee.Tests.Core.Model.DatabaseWrapper wrapper = new Weee.Tests.Core.Model.DatabaseWrapper())
            {
                // Arrange
                Organisation organisation = Organisation.CreateSoleTrader("Test Organisation");
                Scheme scheme = new Scheme(organisation);

                Quarter quarter = new Quarter(2099, QuarterType.Q1);
                DataReturn dataReturn = new DataReturn(scheme, quarter);

                DataReturnVersion version = new DataReturnVersion(dataReturn);

                WeeeCollectedAmount amount1 = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.Dcf,
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                version.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amount1);

                wrapper.WeeeContext.DataReturns.Add(dataReturn);
                await wrapper.WeeeContext.SaveChangesAsync();

                dataReturn.SetCurrentVersion(version);
                await wrapper.WeeeContext.SaveChangesAsync();

                // Act
                FetchSummaryCsvDataAccess dataAccess = new FetchSummaryCsvDataAccess(wrapper.WeeeContext);

                List<DataReturnSummaryCsvData> results = await dataAccess.FetchResultsAsync(scheme.Id, 2099);

                // Assert
                Assert.NotNull(results);
                Assert.Equal(1, results.Count);

                DataReturnSummaryCsvData result = results[0];
                Assert.NotNull(result);

                Assert.NotNull(result.Category1);
                Assert.Null(result.Category2);
                Assert.Null(result.Category3);
                Assert.Null(result.Category4);
                Assert.Null(result.Category5);
                Assert.Null(result.Category6);
                Assert.Null(result.Category7);
                Assert.Null(result.Category8);
                Assert.Null(result.Category9);
                Assert.Null(result.Category10);
                Assert.Null(result.Category11);
                Assert.Null(result.Category12);
                Assert.Null(result.Category13);
                Assert.Null(result.Category14);
            }
        }
        public async Task FetchResultsAsync_WithSeveralOutputAmounts_ReturnsSumOfAmounts()
        {
            using (Weee.Tests.Core.Model.DatabaseWrapper wrapper = new Weee.Tests.Core.Model.DatabaseWrapper())
            {
                // Arrange
                Organisation organisation = Organisation.CreateSoleTrader("Test Organisation");
                Scheme scheme = new Scheme(organisation);

                RegisteredProducer registeredProducer1 = new RegisteredProducer("WEE/AA1111AA", 2099, scheme);
                RegisteredProducer registeredProducer2 = new RegisteredProducer("WEE/BB2222BB", 2099, scheme);

                Quarter quarter = new Quarter(2099, QuarterType.Q1);
                DataReturn dataReturn = new DataReturn(scheme, quarter);

                DataReturnVersion version = new DataReturnVersion(dataReturn);

                EeeOutputAmount amount1 = new EeeOutputAmount(
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    100,
                    registeredProducer1);
                version.EeeOutputReturnVersion.AddEeeOutputAmount(amount1);

                EeeOutputAmount amount2 = new EeeOutputAmount(
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    200,
                    registeredProducer2);
                version.EeeOutputReturnVersion.AddEeeOutputAmount(amount2);

                wrapper.WeeeContext.DataReturns.Add(dataReturn);
                await wrapper.WeeeContext.SaveChangesAsync();

                dataReturn.SetCurrentVersion(version);
                await wrapper.WeeeContext.SaveChangesAsync();

                // Act
                FetchSummaryCsvDataAccess dataAccess = new FetchSummaryCsvDataAccess(wrapper.WeeeContext);

                List<DataReturnSummaryCsvData> results = await dataAccess.FetchResultsAsync(scheme.Id, 2099);

                // Assert
                Assert.NotNull(results);
                Assert.Equal(1, results.Count);

                DataReturnSummaryCsvData result = results[0];
                Assert.NotNull(result);

                Assert.Equal(300, result.Category1);
            }
        }
        public async Task FetchResultsAsync_WithOneAmountOfEachTypeAndSourceAndObligationType_ReturnsResultForEachAmountWithCorrectOrdering()
        {
            using (Weee.Tests.Core.Model.DatabaseWrapper wrapper = new Weee.Tests.Core.Model.DatabaseWrapper())
            {
                // Arrange
                Organisation organisation = Organisation.CreateSoleTrader("Test Organisation");
                Scheme       scheme       = new Scheme(organisation);

                RegisteredProducer registeredProducer1 = new RegisteredProducer("WEE/AA9365AA", 2099, scheme);

                Quarter    quarter    = new Quarter(2099, QuarterType.Q1);
                DataReturn dataReturn = new DataReturn(scheme, quarter);

                DataReturnVersion version = new DataReturnVersion(dataReturn);

                WeeeCollectedAmount amountCollectedDcfB2C = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.Dcf,
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                version.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amountCollectedDcfB2C);

                WeeeCollectedAmount amountCollectedDistributor = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.Distributor,
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                version.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amountCollectedDistributor);

                WeeeCollectedAmount amountCollectedFinalHolder = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.FinalHolder,
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                version.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amountCollectedFinalHolder);

                WeeeDeliveredAmount amountDeliveredAatfB2C = new WeeeDeliveredAmount(
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    new AatfDeliveryLocation("WEE/AA6845AA/ATF", string.Empty));
                version.WeeeDeliveredReturnVersion.AddWeeeDeliveredAmount(amountDeliveredAatfB2C);

                WeeeDeliveredAmount amountDeliveredAeB2C = new WeeeDeliveredAmount(
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    new AeDeliveryLocation("WEE/AA2658AA/AE", string.Empty));
                version.WeeeDeliveredReturnVersion.AddWeeeDeliveredAmount(amountDeliveredAeB2C);

                EeeOutputAmount amountOutputB2C = new EeeOutputAmount(
                    ObligationType.B2C,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    registeredProducer1);
                version.EeeOutputReturnVersion.AddEeeOutputAmount(amountOutputB2C);

                WeeeCollectedAmount amountCollectedDcfB2B = new WeeeCollectedAmount(
                    WeeeCollectedAmountSourceType.Dcf,
                    ObligationType.B2B,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m);
                version.WeeeCollectedReturnVersion.AddWeeeCollectedAmount(amountCollectedDcfB2B);

                WeeeDeliveredAmount amountDeliveredAatfB2B = new WeeeDeliveredAmount(
                    ObligationType.B2B,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    new AatfDeliveryLocation("WEE/AA7445AA/ATF", string.Empty));
                version.WeeeDeliveredReturnVersion.AddWeeeDeliveredAmount(amountDeliveredAatfB2B);

                WeeeDeliveredAmount amountDeliveredAeB2B = new WeeeDeliveredAmount(
                    ObligationType.B2B,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    new AeDeliveryLocation("WEE/AA3658AA/AE", string.Empty));
                version.WeeeDeliveredReturnVersion.AddWeeeDeliveredAmount(amountDeliveredAeB2B);

                EeeOutputAmount amountOutputB2B = new EeeOutputAmount(
                    ObligationType.B2B,
                    WeeeCategory.LargeHouseholdAppliances,
                    123.456m,
                    registeredProducer1);
                version.EeeOutputReturnVersion.AddEeeOutputAmount(amountOutputB2B);

                wrapper.WeeeContext.DataReturns.Add(dataReturn);
                await wrapper.WeeeContext.SaveChangesAsync();

                dataReturn.SetCurrentVersion(version);
                await wrapper.WeeeContext.SaveChangesAsync();

                // Act
                FetchSummaryCsvDataAccess dataAccess = new FetchSummaryCsvDataAccess(wrapper.WeeeContext);

                List <DataReturnSummaryCsvData> results = await dataAccess.FetchResultsAsync(scheme.Id, 2099);

                // Assert
                Assert.NotNull(results);
                Assert.Equal(10, results.Count);
                Assert.Collection(results,
                                  r => { Assert.Equal(0, r.Type); Assert.Equal(0, r.Source); Assert.Equal("B2C", r.ObligationType); },
                                  r => { Assert.Equal(0, r.Type); Assert.Equal(0, r.Source); Assert.Equal("B2B", r.ObligationType); },
                                  r => { Assert.Equal(0, r.Type); Assert.Equal(1, r.Source); Assert.Equal("B2C", r.ObligationType); },
                                  r => { Assert.Equal(0, r.Type); Assert.Equal(2, r.Source); Assert.Equal("B2C", r.ObligationType); },
                                  r => { Assert.Equal(1, r.Type); Assert.Equal(0, r.Source); Assert.Equal("B2C", r.ObligationType); },
                                  r => { Assert.Equal(1, r.Type); Assert.Equal(0, r.Source); Assert.Equal("B2B", r.ObligationType); },
                                  r => { Assert.Equal(1, r.Type); Assert.Equal(1, r.Source); Assert.Equal("B2C", r.ObligationType); },
                                  r => { Assert.Equal(1, r.Type); Assert.Equal(1, r.Source); Assert.Equal("B2B", r.ObligationType); },
                                  r => { Assert.Equal(2, r.Type); Assert.Equal(null, r.Source); Assert.Equal("B2C", r.ObligationType); },
                                  r => { Assert.Equal(2, r.Type); Assert.Equal(null, r.Source); Assert.Equal("B2B", r.ObligationType); });
            }
        }
        public async Task Build_ExistingLatestSubmittedDataReturnVersion_WithSomeExistingEeeOutputAmounts_ReturnsDataReturnVersionWithExistingEeeOutputAmounts()
        {
            var registeredProducer1 = A.Fake<RegisteredProducer>();
            A.CallTo(() => registeredProducer1.ProducerRegistrationNumber)
                .Returns("Producer1");
            A.CallTo(() => registeredProducer1.Equals(A<RegisteredProducer>._))
                .Returns(true);

            var registeredProducer2 = A.Fake<RegisteredProducer>();
            A.CallTo(() => registeredProducer2.ProducerRegistrationNumber)
                .Returns("Producer2");
            A.CallTo(() => registeredProducer2.Equals(A<RegisteredProducer>._))
                .Returns(true);

            var eeeOutputAmount1 = new EeeOutputAmount(ObligationType.B2C, WeeeCategory.ConsumerEquipment, 100, registeredProducer1);
            var eeeOutputAmount2 = new EeeOutputAmount(ObligationType.B2C, WeeeCategory.MedicalDevices, 200, registeredProducer1);
            var eeeOutputAmount3 = new EeeOutputAmount(ObligationType.B2C, WeeeCategory.ToysLeisureAndSports, 100, registeredProducer2);
            var eeeOutputAmount4 = new EeeOutputAmount(ObligationType.B2C, WeeeCategory.ConsumerEquipment, 150, registeredProducer2);

            var eeeOutputReturnVersion = new EeeOutputReturnVersion();
            eeeOutputReturnVersion.AddEeeOutputAmount(eeeOutputAmount1);
            eeeOutputReturnVersion.AddEeeOutputAmount(eeeOutputAmount2);
            eeeOutputReturnVersion.AddEeeOutputAmount(eeeOutputAmount3);
            eeeOutputReturnVersion.AddEeeOutputAmount(eeeOutputAmount4);

            var dataReturn = new DataReturn(A.Dummy<Scheme>(), A.Dummy<Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, A.Dummy<WeeeCollectedReturnVersion>(),
                A.Dummy<WeeeDeliveredReturnVersion>(), eeeOutputReturnVersion);
            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
               .Returns(dataReturn);

            A.CallTo(() => helper.DataAccess.GetRegisteredProducer("Producer1"))
                .Returns(registeredProducer1);

            A.CallTo(() => helper.DataAccess.GetRegisteredProducer("Producer2"))
                .Returns(registeredProducer2);

            var builder = helper.Create();
            await builder.AddEeeOutputAmount("Producer1", "ProducerName", WeeeCategory.MedicalDevices, ObligationType.B2C, 200);
            await builder.AddEeeOutputAmount("Producer2", "ProducerName", WeeeCategory.ToysLeisureAndSports, ObligationType.B2C, 100);

            var result = await builder.Build();

            Assert.NotSame(eeeOutputReturnVersion, result.DataReturnVersion.EeeOutputReturnVersion);
            Assert.Collection(result.DataReturnVersion.EeeOutputReturnVersion.EeeOutputAmounts,
                r1 => Assert.Same(eeeOutputAmount2, r1),
                r2 => Assert.Same(eeeOutputAmount3, r2));
        }
        public async Task Build_ExistingLatestSubmittedDataReturnVersion_DoesNotContainReturnData_WithNoDataForNewReturn_ReturnsNullReturnVersions()
        {
            var dataReturn = new DataReturn(A.Dummy<Scheme>(), A.Dummy<Quarter>());
            var dataReturnVersion = new DataReturnVersion(dataReturn, null, null, null);
            dataReturn.SetCurrentVersion(dataReturnVersion);

            var helper = new DataReturnVersionBuilderHelper();

            A.CallTo(() => helper.DataAccess.FetchDataReturnOrDefault())
               .Returns(dataReturn);

            var builder = helper.Create();

            var result = await builder.Build();

            Assert.Null(result.DataReturnVersion.WeeeCollectedReturnVersion);
            Assert.Null(result.DataReturnVersion.WeeeDeliveredReturnVersion);
            Assert.Null(result.DataReturnVersion.EeeOutputReturnVersion);
        }
        public void CreateResults_WithQ1DeliveredAmountOfZero_PopulatesDeliveredQ1AndDeliveredTotalWithZero()
        {
            // Arrange
            DataReturn dataReturn = new DataReturn(A.Dummy<Domain.Scheme.Scheme>(), new Quarter(2016, QuarterType.Q1));

            DataReturnVersion dataReturnVersion = new DataReturnVersion(dataReturn);

            WeeeDeliveredAmount weeeDeliveredAmount = new WeeeDeliveredAmount(
                DomainObligationType.B2C,
                WeeeCategory.LargeHouseholdAppliances,
                0,
                new AatfDeliveryLocation("WEE/AA1234AA/ATF", "Facility Name"));

            dataReturnVersion.WeeeDeliveredReturnVersion.AddWeeeDeliveredAmount(weeeDeliveredAmount);

            dataReturn.SetCurrentVersion(dataReturnVersion);

            GetUkWeeeCsvHandler handler = new GetUkWeeeCsvHandler(
                A.Dummy<IWeeeAuthorization>(),
                A.Dummy<IGetUkWeeeCsvDataAccess>(),
                A.Dummy<CsvWriterFactory>());

            // Act
            IEnumerable<GetUkWeeeCsvHandler.CsvResult> results = handler.CreateResults(new List<DataReturn>() { dataReturn });

            // Assert
            GetUkWeeeCsvHandler.CsvResult result = results
                .Single(r => r.Category == WeeeCategory.LargeHouseholdAppliances && r.ObligationType == DomainObligationType.B2C);
            Assert.NotNull(result);

            Assert.Equal(0, result.DeliveredQ1);
            Assert.Equal(null, result.DeliveredQ2);
            Assert.Equal(null, result.DeliveredQ3);
            Assert.Equal(null, result.DeliveredQ4);
            Assert.Equal(0, result.DeliveredTotal);
        }