当前位置: 首页>>代码示例>>C#>>正文


C# ModelHelper.CreateDataReturnVersion方法代码示例

本文整理汇总了C#中ModelHelper.CreateDataReturnVersion方法的典型用法代码示例。如果您正苦于以下问题:C# ModelHelper.CreateDataReturnVersion方法的具体用法?C# ModelHelper.CreateDataReturnVersion怎么用?C# ModelHelper.CreateDataReturnVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelHelper的用法示例。


在下文中一共展示了ModelHelper.CreateDataReturnVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute_HappyPath_ReturnsProducerEeeDataHistory

        public async Task Execute_HappyPath_ReturnsProducerEeeDataHistory()
        {
            using (DatabaseWrapper db = new DatabaseWrapper())
            {
                //Arrange
                ModelHelper helper = new ModelHelper(db.Model);
                var scheme1 = helper.CreateScheme();
                scheme1.ApprovalNumber = "WEE/TE0000ST/SCH";
                var memberUpload1 = helper.CreateSubmittedMemberUpload(scheme1);
                memberUpload1.ComplianceYear = 2000;

                var producer1 = helper.CreateProducerAsCompany(memberUpload1, "PRN123");
                producer1.ObligationType = "B2B";
                var dataReturnVersion1 = helper.CreateDataReturnVersion(scheme1, 2000, 1);
                dataReturnVersion1.SubmittedDate = new DateTime(2015, 1, 6);
                var dataReturnVersion2 = helper.CreateDataReturnVersion(scheme1, 2000, 2);
                dataReturnVersion2.SubmittedDate = new DateTime(2015, 1, 8);

                helper.CreateEeeOutputAmount(dataReturnVersion1, producer1.RegisteredProducer, "B2B", 1, 100);
                helper.CreateEeeOutputAmount(dataReturnVersion2, producer1.RegisteredProducer, "B2B", 2, 200);

                var scheme2 = helper.CreateScheme();
                scheme2.ApprovalNumber = "WEE/TE0000S1/SCH";
                var memberUpload2 = helper.CreateSubmittedMemberUpload(scheme2);
                memberUpload2.ComplianceYear = 2000;

                var producer2 = helper.CreateProducerAsCompany(memberUpload2, "PRN123");
                producer2.ObligationType = "B2C";
                var dataReturnVersion3 = helper.CreateDataReturnVersion(scheme2, 2000, 1);
                dataReturnVersion1.SubmittedDate = new DateTime(2015, 1, 9);
                var dataReturnVersion4 = helper.CreateDataReturnVersion(scheme2, 2000, 2);
                dataReturnVersion4.SubmittedDate = new DateTime(2015, 1, 10);

                helper.CreateEeeOutputAmount(dataReturnVersion3, producer2.RegisteredProducer, "B2C", 1, 40);
                helper.CreateEeeOutputAmount(dataReturnVersion4, producer2.RegisteredProducer, "B2C", 2, 1000);

                db.Model.SaveChanges();

                // Act
                var results = await db.StoredProcedures.SpgProducerEeeHistoryCsvData("PRN123");

                //Assert
                Assert.NotNull(results);

                ProducerEeeHistoryCsvData.ProducerInReturnsResult b2cProducer = results.ProducerReturnsHistoryData.Find(x => (x.ApprovalNumber == "WEE/TE0000S1/SCH"));
                Assert.NotNull(b2cProducer);
                Assert.Equal(2000, b2cProducer.ComplianceYear);
                Assert.Equal(1000, b2cProducer.Cat2B2C);
                Assert.Equal("Yes", b2cProducer.LatestData);

                ProducerEeeHistoryCsvData.ProducerInReturnsResult b2bProducer = results.ProducerReturnsHistoryData.Find(x => (x.ApprovalNumber == "WEE/TE0000ST/SCH"));
                Assert.NotNull(b2bProducer);
                Assert.Equal(2000, b2bProducer.ComplianceYear);
                Assert.Equal(200, b2bProducer.Cat2B2B);
                Assert.Null(b2bProducer.Cat2B2C);
                Assert.Equal("Yes", b2bProducer.LatestData);

                Assert.Equal(4, results.ProducerReturnsHistoryData.Count);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:60,代码来源:SpgProducerEeeDataHistoryCsvTests.cs

示例2: GetPreviousSubmission_ReturnsNullIfPreviousUploadButNoSubmission

        public async Task GetPreviousSubmission_ReturnsNullIfPreviousUploadButNoSubmission()
        {
            using (var database = new DatabaseWrapper())
            {
                // Arrange
                DataReturnSubmissionsDataAccess dataAccess = new DataReturnSubmissionsDataAccess(database.WeeeContext);

                ModelHelper modelHelper = new ModelHelper(database.Model);
                DomainHelper domainHelper = new DomainHelper(database.WeeeContext);

                var scheme = modelHelper.CreateScheme();

                var dataReturnVersion = modelHelper.CreateDataReturnVersion(scheme, 2015, 1, false);

                var dataReturnVersion2 = modelHelper.CreateDataReturnVersion(scheme, 2015, 1, true);
                dataReturnVersion2.SubmittedDate = new DateTime(2015, 2, 1);

                database.Model.SaveChanges();

                var domainDataReturnVersion = domainHelper.GetDataReturnVersion(dataReturnVersion2.Id);

                // Act
                var result = await dataAccess.GetPreviousSubmission(domainDataReturnVersion);

                // Assert
                Assert.Null(result);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:28,代码来源:DataReturnSubmissionsDataAccessTests.cs

示例3: GetPreviousSubmission_ReturnsPreviousSubmissionForSameSchemeOnly

        public async Task GetPreviousSubmission_ReturnsPreviousSubmissionForSameSchemeOnly()
        {
            using (var database = new DatabaseWrapper())
            {
                // Arrange
                DataReturnSubmissionsDataAccess dataAccess = new DataReturnSubmissionsDataAccess(database.WeeeContext);

                ModelHelper modelHelper = new ModelHelper(database.Model);
                DomainHelper domainHelper = new DomainHelper(database.WeeeContext);

                var scheme1 = modelHelper.CreateScheme();

                var dataReturnVersion = modelHelper.CreateDataReturnVersion(scheme1, 2015, 1, true);
                dataReturnVersion.SubmittedDate = new DateTime(2015, 1, 1);

                var dataReturnVersion2 = modelHelper.CreateDataReturnVersion(scheme1, 2015, 1, true);
                dataReturnVersion2.SubmittedDate = new DateTime(2015, 3, 1);

                var scheme2 = modelHelper.CreateScheme();

                var dataReturnVersion3 = modelHelper.CreateDataReturnVersion(scheme2, 2015, 1, true);
                dataReturnVersion3.SubmittedDate = new DateTime(2015, 2, 1);

                database.Model.SaveChanges();

                var domainDataReturnVersion = domainHelper.GetDataReturnVersion(dataReturnVersion2.Id);

                // Act
                var result = await dataAccess.GetPreviousSubmission(domainDataReturnVersion);

                // Assert
                Assert.NotNull(result);
                Assert.Equal(dataReturnVersion.Id, result.Id);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:35,代码来源:DataReturnSubmissionsDataAccessTests.cs

示例4: FetchDataReturnOrDefault_ReturnsDataReturnForSpecifiedYearOnly

        public async Task FetchDataReturnOrDefault_ReturnsDataReturnForSpecifiedYearOnly()
        {
            using (DatabaseWrapper database = new DatabaseWrapper())
            {
                // Arrange
                ModelHelper helper = new ModelHelper(database.Model);
                DomainHelper domainHelper = new DomainHelper(database.WeeeContext);

                var scheme = helper.CreateScheme();
                helper.CreateDataReturnVersion(scheme, 2016, 1, true);

                var dataReturnVersion = helper.CreateDataReturnVersion(scheme, 2017, 1, true);

                database.Model.SaveChanges();

                var dataAccess = new DataReturnVersionBuilderDataAccess(domainHelper.GetScheme(scheme.Id), new Quarter(2017, QuarterType.Q1), database.WeeeContext);

                // Act
                var result = await dataAccess.FetchDataReturnOrDefault();

                // Assert
                Assert.Equal(2017, result.Quarter.Year);
                Assert.Equal(dataReturnVersion.DataReturn.Id, result.Id);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:25,代码来源:DataReturnVersionBuilderDataAccessTests.cs

示例5: DataAccess_ReturnsOnlyB2CSchemeForProducer_WhenTheyAreRegisteredB2BandB2COverTwoSchemesInCurrentYear

        public async void DataAccess_ReturnsOnlyB2CSchemeForProducer_WhenTheyAreRegisteredB2BandB2COverTwoSchemesInCurrentYear()
        {
            using (var db = new DatabaseWrapper())
            {
                //Arrange
                ModelHelper helper = new ModelHelper(db.Model);
                var scheme1 = helper.CreateScheme();
                scheme1.ApprovalNumber = "WEE/TE0001ST/SCH";
                var scheme2 = helper.CreateScheme();
                scheme2.ApprovalNumber = "WEE/TE0002ST/SCH";

                //Previous Year Data
                //This test is registering the producer over two schemes in the previous year as well as the current
                //year to test the additional complexity
                var memberUpload2000s1 = helper.CreateSubmittedMemberUpload(scheme1);
                memberUpload2000s1.ComplianceYear = 2000;
                var prod1_2000s1 = helper.CreateProducerAsCompany(memberUpload2000s1, "PRN123", "B2B");
                var dataReturnVersion1 = helper.CreateDataReturnVersion(scheme1, 2000, 1);
                helper.CreateEeeOutputAmount(dataReturnVersion1, prod1_2000s1.RegisteredProducer, "B2B", 1, 500);

                var memberUpload2000s2 = helper.CreateSubmittedMemberUpload(scheme2);
                memberUpload2000s2.ComplianceYear = 2000;
                var prod1_2000s2 = helper.CreateProducerAsCompany(memberUpload2000s2, "PRN123", "B2C");
                var dataReturnVersion2 = helper.CreateDataReturnVersion(scheme2, 2000, 1);
                helper.CreateEeeOutputAmount(dataReturnVersion2, prod1_2000s2.RegisteredProducer, "B2C", 1, 70);

                //Current Year Data
                var memberUpload2001s1 = helper.CreateSubmittedMemberUpload(scheme1);
                memberUpload2001s1.ComplianceYear = 2001;
                var prod1_2001s1 = helper.CreateProducerAsCompany(memberUpload2001s1, "PRN123", "B2C");
                var dataReturnVersion3 = helper.CreateDataReturnVersion(scheme1, 2001, 1);
                helper.CreateEeeOutputAmount(dataReturnVersion3, prod1_2001s1.RegisteredProducer, "B2C", 1, 5000);

                var memberUpload2001s2 = helper.CreateSubmittedMemberUpload(scheme2);
                memberUpload2001s2.ComplianceYear = 2001;
                helper.CreateProducerAsCompany(memberUpload2001s2, "PRN123", "B2B");

                db.Model.SaveChanges();

                // Act
                GetSchemeObligationCsvDataProcessor obligationDataAccess = new GetSchemeObligationCsvDataProcessor(db.WeeeContext);
                var results = await obligationDataAccess.FetchObligationsForComplianceYearAsync(2001);

                // Assert
                Assert.NotNull(results);

                Assert.Equal(1, results.Count);
                SchemeObligationCsvData result1 = results.Find(x => (x.ApprovalNumber == "WEE/TE0001ST/SCH"));
                Assert.Equal("PRN123", result1.PRN);
                Assert.Equal("B2C", result1.ObligationTypeForPreviousYear);
                Assert.Equal("B2C", result1.ObligationTypeForSelectedYear);
                Assert.Equal(70, result1.Cat1B2CTotal);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:54,代码来源:GetSchemeObligationDataCsvHandlerTests.cs

示例6: Execute_HappyPath_ReturnsProducerEeeForPreviousYear

        public async Task Execute_HappyPath_ReturnsProducerEeeForPreviousYear()
        {
            using (DatabaseWrapper db = new DatabaseWrapper())
            {
                //Arrange
                ModelHelper helper = new ModelHelper(db.Model);
                var scheme = helper.CreateScheme();
                scheme.ApprovalNumber = "WEE/TE0000ST/SCH";

                //Previous Year Data
                var memberUpload2000 = helper.CreateSubmittedMemberUpload(scheme);
                memberUpload2000.ComplianceYear = 2000;
                var prod1_2000 = helper.CreateProducerAsCompany(memberUpload2000, "PRN123", "B2C");
                var prod2_2000 = helper.CreateProducerAsCompany(memberUpload2000, "PRN456", "B2B");
                var dataReturnVersion1 = helper.CreateDataReturnVersion(scheme, 2000, 1);
                var dataReturnVersion2 = helper.CreateDataReturnVersion(scheme, 2000, 2);
                helper.CreateEeeOutputAmount(dataReturnVersion1, prod1_2000.RegisteredProducer, "B2C", 1, 100);
                helper.CreateEeeOutputAmount(dataReturnVersion2, prod1_2000.RegisteredProducer, "B2C", 2, 1000);
                helper.CreateEeeOutputAmount(dataReturnVersion1, prod2_2000.RegisteredProducer, "B2B", 2, 400);

                //Current Year Data
                var memberUpload2001 = helper.CreateSubmittedMemberUpload(scheme);
                memberUpload2001.ComplianceYear = 2001;
                var prod1_2001 = helper.CreateProducerAsCompany(memberUpload2001, "PRN123", "B2C");
                var prod2_2001 = helper.CreateProducerAsCompany(memberUpload2001, "PRN456", "B2B");
                var dataReturnVersion3 = helper.CreateDataReturnVersion(scheme, 2001, 1);
                var dataReturnVersion4 = helper.CreateDataReturnVersion(scheme, 2001, 2);
                helper.CreateEeeOutputAmount(dataReturnVersion3, prod1_2001.RegisteredProducer, "B2C", 1, 3000);
                helper.CreateEeeOutputAmount(dataReturnVersion4, prod1_2001.RegisteredProducer, "B2C", 2, 600);
                helper.CreateEeeOutputAmount(dataReturnVersion3, prod2_2001.RegisteredProducer, "B2B", 2, 9000);

                db.Model.SaveChanges();

                // Act
                var results = await db.StoredProcedures.SpgSchemeObligationDataCsv(2001);

                //Assert
                Assert.NotNull(results);

                //Producer with only B2B (both years) should not be in data
                SchemeObligationCsvData b2bProducer = results.Find(x => (x.PRN == "PRN456"));
                Assert.Null(b2bProducer);

                Assert.Equal(1, results.Count);
                SchemeObligationCsvData result = results[0];
                Assert.Equal("test scheme name", result.SchemeName);
                Assert.Equal("WEE/TE0000ST/SCH", result.ApprovalNumber);
                Assert.Equal("PRN123", result.PRN);
                Assert.Equal(100, result.Cat1B2CTotal);
                Assert.Equal(1000, result.Cat2B2CTotal);
                Assert.Null(result.Cat3B2CTotal);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:53,代码来源:SpgSchemeObligationCsvDataTests.cs

示例7: Submit_SetsDataReturnVersionAsSubmitted

        public async Task Submit_SetsDataReturnVersionAsSubmitted()
        {
            using (DatabaseWrapper database = new DatabaseWrapper())
            {
                // Arrange
                ModelHelper helper = new ModelHelper(database.Model);
                DomainHelper domainHelper = new DomainHelper(database.WeeeContext);

                var scheme = helper.CreateScheme();
                var dataReturnVersion = helper.CreateDataReturnVersion(scheme, 2016, 1, false);

                database.Model.SaveChanges();

                var dbDataReturnVersion = domainHelper.GetDataReturnVersion(dataReturnVersion.Id);
                var dataAccess = new SubmitReturnVersionDataAccess(database.WeeeContext);

                // Act
                await dataAccess.Submit(dbDataReturnVersion);

                // Assert
                Assert.Equal(dataReturnVersion.Id, dbDataReturnVersion.Id);
                Assert.True(dbDataReturnVersion.IsSubmitted);
                Assert.NotNull(dbDataReturnVersion.SubmittedDate);
                Assert.Equal(database.WeeeContext.GetCurrentUser(), dbDataReturnVersion.SubmittingUserId);
                Assert.Equal(dataReturnVersion.Id, dbDataReturnVersion.DataReturn.CurrentVersion.Id);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:27,代码来源:SubmitReturnVersionDataAccessTests.cs

示例8: GetLatestProducerEeeData_ReturnsNull_WhenDataNotAvailableForSpecifiedProducer

        public async Task GetLatestProducerEeeData_ReturnsNull_WhenDataNotAvailableForSpecifiedProducer()
        {
            using (DatabaseWrapper database = new DatabaseWrapper())
            {
                // Arrange
                var helper = new ModelHelper(database.Model);

                var organisation = helper.CreateOrganisation();
                var scheme = helper.CreateScheme(organisation);

                var memberUpload = helper.CreateSubmittedMemberUpload(scheme);
                memberUpload.ComplianceYear = 2016;

                var producer = helper.CreateProducerAsCompany(memberUpload, "WEE/MM0001AA");

                var dataReturnVersion = helper.CreateDataReturnVersion(scheme, 2016, 1, isSubmitted: true);
                var producerEee = helper.CreateEeeOutputAmount(dataReturnVersion, producer.RegisteredProducer, "B2C", 1, 1000);

                database.Model.SaveChanges();

                // Act
                var querySet = new SchemeEeeDataQuerySet(organisation.Id, "2016", database.WeeeContext);
                var result = await querySet.GetLatestProducerEeeData("WEE/MM0001BB");

                // Assert
                Assert.Null(result);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:28,代码来源:SchemeEeeDataQuerySetTests.cs

示例9: Execute_HappyPath_ReturnsProducerEeeWithSelectedYearAndObligationType

        public async Task Execute_HappyPath_ReturnsProducerEeeWithSelectedYearAndObligationType()
        {
            using (DatabaseWrapper db = new DatabaseWrapper())
            {
                //Arrange
                ModelHelper helper = new ModelHelper(db.Model);
                var scheme = helper.CreateScheme();
                scheme.ApprovalNumber = "WEE/TE0000ST/SCH";
                var memberUpload = helper.CreateSubmittedMemberUpload(scheme);
                memberUpload.ComplianceYear = 2000;

                var producer1 = helper.CreateProducerAsCompany(memberUpload, "PRN123");
                var producer2 = helper.CreateProducerAsCompany(memberUpload, "PRN456");

                var dataReturnVersion1 = helper.CreateDataReturnVersion(scheme, 2000, 1);
                var dataReturnVersion2 = helper.CreateDataReturnVersion(scheme, 2000, 2);

                helper.CreateEeeOutputAmount(dataReturnVersion1, producer1.RegisteredProducer, "B2C", 1, 100);
                helper.CreateEeeOutputAmount(dataReturnVersion2, producer1.RegisteredProducer, "B2C", 2, 1000);

                helper.CreateEeeOutputAmount(dataReturnVersion1, producer2.RegisteredProducer, "B2B", 2, 400);

                db.Model.SaveChanges();

                // Act
                var results = await db.StoredProcedures.SpgProducerEeeCsvData(2000, null, "B2C");

                //Assert
                Assert.NotNull(results);

                //Data return with obliation type B2B should not be there in the result.
                ProducerEeeCsvData b2bProducer = results.Find(x => (x.PRN == "PRN456"));
                Assert.Null(b2bProducer);

                ProducerEeeCsvData result = results[0];
                Assert.Equal("test scheme name", result.SchemeName);
                Assert.Equal("WEE/TE0000ST/SCH", result.ApprovalNumber);
                Assert.Equal("PRN123", result.PRN);
                Assert.Equal(100, result.Cat1Q1);
                Assert.Equal(1000, result.Cat2Q2);
                Assert.Equal(1100, result.TotalTonnage);
                Assert.Null(result.Cat1Q3);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:44,代码来源:SpgProducerEeeCsvDataTests.cs

示例10: Execute_ReturnsCorrectTotalsForCategories_OfB2COnlyForPreviousYearOfCorrectProducer

        public async Task Execute_ReturnsCorrectTotalsForCategories_OfB2COnlyForPreviousYearOfCorrectProducer()
        {
            using (DatabaseWrapper db = new DatabaseWrapper())
            {
                //Arrange
                ModelHelper helper = new ModelHelper(db.Model);
                var scheme = helper.CreateScheme();
                scheme.ApprovalNumber = "WEE/TE0000ST/SCH";

                //Previous Year Data
                var memberUpload2000 = helper.CreateSubmittedMemberUpload(scheme);
                memberUpload2000.ComplianceYear = 2000;
                var prod1_2000 = helper.CreateProducerAsCompany(memberUpload2000, "PRN123", "Both");
                var prod2_2000 = helper.CreateProducerAsCompany(memberUpload2000, "PRN456", "B2C");
                var dataReturnVersion1 = helper.CreateDataReturnVersion(scheme, 2000, 1);
                var dataReturnVersion2 = helper.CreateDataReturnVersion(scheme, 2000, 2);
                helper.CreateEeeOutputAmount(dataReturnVersion1, prod1_2000.RegisteredProducer, "B2C", 1, 100); // Prod1 Cat1 B2C Q1
                helper.CreateEeeOutputAmount(dataReturnVersion1, prod1_2000.RegisteredProducer, "B2C", 2, 500); // Prod1 Cat2 B2C Q1
                helper.CreateEeeOutputAmount(dataReturnVersion2, prod1_2000.RegisteredProducer, "B2C", 2, 1000); // Prod1 Cat2 B2C Q2
                helper.CreateEeeOutputAmount(dataReturnVersion1, prod1_2000.RegisteredProducer, "B2B", 2, 50); // Prod1 Cat2 B2B Q1
                helper.CreateEeeOutputAmount(dataReturnVersion1, prod2_2000.RegisteredProducer, "B2C", 2, 400); // Prod2 Cat2 B2C Q1

                //Current Year Data
                var memberUpload2001 = helper.CreateSubmittedMemberUpload(scheme);
                memberUpload2001.ComplianceYear = 2001;
                var prod1_2001 = helper.CreateProducerAsCompany(memberUpload2001, "PRN123", "B2C");
                var prod2_2001 = helper.CreateProducerAsCompany(memberUpload2001, "PRN456", "B2B");
                var dataReturnVersion3 = helper.CreateDataReturnVersion(scheme, 2001, 1);
                var dataReturnVersion4 = helper.CreateDataReturnVersion(scheme, 2001, 2);
                helper.CreateEeeOutputAmount(dataReturnVersion3, prod1_2001.RegisteredProducer, "B2C", 1, 3000);
                helper.CreateEeeOutputAmount(dataReturnVersion4, prod1_2001.RegisteredProducer, "B2C", 2, 600);
                helper.CreateEeeOutputAmount(dataReturnVersion3, prod2_2001.RegisteredProducer, "B2B", 2, 9000);

                db.Model.SaveChanges();

                // Act
                var results = await db.StoredProcedures.SpgSchemeObligationDataCsv(2001);

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

                SchemeObligationCsvData firstProducer = results.Find(x => (x.PRN == "PRN123"));

                Assert.Equal("PRN123", firstProducer.PRN);
                Assert.Equal(100, firstProducer.Cat1B2CTotal);
                Assert.Equal(1500, firstProducer.Cat2B2CTotal);
                Assert.Null(firstProducer.Cat3B2CTotal);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:50,代码来源:SpgSchemeObligationCsvDataTests.cs

示例11: Get_TwoUploadsForTheSameComplianceYear_OnlyReturnsTheYearOnce

        public async void Get_TwoUploadsForTheSameComplianceYear_OnlyReturnsTheYearOnce()
        {
            using (var database = new DatabaseWrapper())
            {
                const int complianceYear = 2995;

                // Arrange
                var modelHelper = new ModelHelper(database.Model);

                var organisation = modelHelper.CreateOrganisation();
                await database.Model.SaveChangesAsync();

                var scheme = modelHelper.CreateScheme(organisation);
                await database.Model.SaveChangesAsync();

                var firstDataReturn = modelHelper.CreateDataReturn(scheme, complianceYear, (int)QuarterType.Q1);
                await database.Model.SaveChangesAsync();

                var firstDataReturnVersion = modelHelper.CreateDataReturnVersion(scheme, complianceYear, (int)QuarterType.Q1, true, firstDataReturn);
                modelHelper.CreateDataReturnUpload(scheme, firstDataReturnVersion);
                await database.Model.SaveChangesAsync();

                var secondDataReturn = modelHelper.CreateDataReturn(scheme, complianceYear, (int)QuarterType.Q2);
                await database.Model.SaveChangesAsync();

                var secondDataReturnVersion = modelHelper.CreateDataReturnVersion(scheme, complianceYear, (int)QuarterType.Q2, true, secondDataReturn);
                modelHelper.CreateDataReturnUpload(scheme, secondDataReturnVersion);
                await database.Model.SaveChangesAsync();

                // Act
                var dataAccess = new GetDataReturnsActiveComplianceYearsDataAccess(database.WeeeContext);
                var result = await dataAccess.Get();

                // Assert
                Assert.Single(result.Where(y => y == complianceYear));
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:37,代码来源:GetDataReturnsActiveComplianceYearsDataAccessTests.cs

示例12: GivenSomeCollectedWeeeExists_StoredProcedureReturnsThatDataSuccessfully

        public async Task GivenSomeCollectedWeeeExists_StoredProcedureReturnsThatDataSuccessfully()
        {
            const int complianceYear = 1372;
            const ObligationType obligationType = ObligationType.B2B;
            const int collectedTonnage = 179;
            const WeeeCategory category = WeeeCategory.AutomaticDispensers;
            const QuarterType quarterType = QuarterType.Q1;

            using (var dbWrapper = new DatabaseWrapper())
            {
                var modelHelper = new ModelHelper(dbWrapper.Model);

                var org = modelHelper.CreateOrganisation();

                var scheme = modelHelper.CreateScheme(org);
                scheme.ObligationType = (int)obligationType;

                var weeeCollectedReturnVersion = modelHelper.CreateWeeeCollectedReturnVersion();

                modelHelper.CreateDataReturnVersion(scheme, complianceYear, (int)quarterType, true, null, weeeCollectedReturnVersion);

                await dbWrapper.Model.SaveChangesAsync();

                var weeeCollectedAmount = modelHelper.CreateWeeeCollectedAmount(obligationType, collectedTonnage, category);

                modelHelper.CreateWeeeCollectedReturnVersionAmount(weeeCollectedAmount, weeeCollectedReturnVersion);

                await dbWrapper.Model.SaveChangesAsync();

                var results =
                    await dbWrapper.StoredProcedures.SpgSchemeWeeeCsvAsync(complianceYear, null, obligationType.ToString());

                Assert.NotEmpty(results.CollectedAmounts);

                var collectedAmountResult = results.CollectedAmounts.Single(ca => ca.SchemeId == scheme.Id);

                Assert.NotNull(collectedAmountResult);
                Assert.Equal((int)quarterType, collectedAmountResult.QuarterType);
                Assert.Equal(collectedTonnage, collectedAmountResult.Tonnage);
                Assert.Equal((int)category, collectedAmountResult.WeeeCategory);

                var schemeResult = results.Schemes.Single(s => s.SchemeId == scheme.Id);

                Assert.NotNull(schemeResult);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:46,代码来源:SpgSchemeWeeeCsvAsyncTests.cs

示例13: Execute_ReturnsEeeData_ForNonRemovedProducersOnly

        public async Task Execute_ReturnsEeeData_ForNonRemovedProducersOnly()
        {
            using (DatabaseWrapper db = new DatabaseWrapper())
            {
                // Arrange
                ModelHelper helper = new ModelHelper(db.Model);

                var scheme = helper.CreateScheme();
                var memberUpload = helper.CreateSubmittedMemberUpload(scheme);
                memberUpload.ComplianceYear = 2000;

                var producer1 = helper.CreateProducerAsCompany(memberUpload, "PRN123");
                producer1.RegisteredProducer.Removed = true;

                var producer2 = helper.CreateProducerAsCompany(memberUpload, "PRN789");

                var dataReturnVersion = helper.CreateDataReturnVersion(scheme, 2000, 1);

                helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 1, 100);
                helper.CreateEeeOutputAmount(dataReturnVersion, producer2.RegisteredProducer, "B2C", 1, 200);

                db.Model.SaveChanges();

                // Act
                var results =
                    await db.StoredProcedures.SpgProducerEeeCsvData(2000, null, "B2C");

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

                var data = results.Single();

                Assert.Equal("PRN789", data.PRN);
                Assert.Equal(200, data.Cat1Q1);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:36,代码来源:SpgProducerEeeCsvDataTests.cs

示例14: using

        public async void GetComplianceYearsWithSubmittedDataReturns_SchemeHasSubmittedDataReturn_ReturnsCorrespondingComplianceYear()
        {
            const int complianceYear = 1666;
            const int quarter = 4;

            using (var databaseWrapper = new DatabaseWrapper())
            {
                // Arrange
                var modelHelper = new ModelHelper(databaseWrapper.Model);

                var scheme = modelHelper.CreateScheme();
                var dataReturn = modelHelper.CreateDataReturn(scheme, complianceYear, quarter);
                modelHelper.CreateDataReturnVersion(scheme, complianceYear, quarter, true,
                    dataReturn);

                await databaseWrapper.Model.SaveChangesAsync();

                // Act
                var dataAccess = new SchemeDataAccess(databaseWrapper.WeeeContext);

                var result = await dataAccess.GetComplianceYearsWithSubmittedDataReturns(scheme.Id);

                // Assert
                Assert.Single(result);
                Assert.Equal(complianceYear, result.Single());
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:27,代码来源:SchemeDataAccessTests.cs

示例15: HandleAsync_XmlDoesNotContainSchemaError_StoresAvailableDataReturnData

        public async Task HandleAsync_XmlDoesNotContainSchemaError_StoresAvailableDataReturnData()
        {
            using (DatabaseWrapper database = new DatabaseWrapper())
            {
                // Arrange
                ModelHelper helper = new ModelHelper(database.Model);
                DomainHelper domainHelper = new DomainHelper(database.WeeeContext);

                var organisation = helper.CreateOrganisation();
                var scheme = helper.CreateScheme(organisation);
                var dataReturnVersion = helper.CreateDataReturnVersion(scheme, 2016, 3, false);

                database.Model.SaveChanges();

                var builder = new ProcessDataReturnXmlFileHandlerBuilder(database.WeeeContext);

                var schemeReturn = new SchemeReturn()
                {
                    ComplianceYear = "2016",
                    ReturnPeriod = SchemeReturnReturnPeriod.Quarter3JulySeptember
                };

                var xmlGeneratorResult = new GenerateFromDataReturnXmlResult<SchemeReturn>(
                    "Test XML string",
                    schemeReturn,
                    new List<XmlValidationError>());

                A.CallTo(() => builder.XmlGenerator.GenerateDataReturns<SchemeReturn>(A<ProcessDataReturnXmlFile>._))
                     .Returns(xmlGeneratorResult);

                var dbDataReturnVersion = domainHelper.GetDataReturnVersion(dataReturnVersion.Id);
                var dataReturnVersionBuilderResult = new DataReturnVersionBuilderResult(dbDataReturnVersion, A.Dummy<List<ErrorData>>());

                A.CallTo(() => builder.DataReturnVersionFromXmlBuilder.Build(A<SchemeReturn>._))
                    .Returns(dataReturnVersionBuilderResult);

                // Act
                var dataReturnUploadId = await builder.InvokeHandleAsync(organisation.Id, fileName: "XML file name");

                // Assert
                var dataReturnUpload = domainHelper.GetDataReturnUpload(dataReturnUploadId);

                Assert.Equal(scheme.Id, dataReturnUpload.Scheme.Id);
                Assert.Equal("Test XML string", dataReturnUpload.RawData.Data);
                Assert.Equal("XML file name", dataReturnUpload.FileName);
                Assert.Equal(2016, dataReturnUpload.ComplianceYear);
                Assert.Equal(Convert.ToInt32(QuarterType.Q3), dataReturnUpload.Quarter);
                Assert.NotEqual(TimeSpan.Zero, dataReturnUpload.ProcessTime);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:50,代码来源:ProcessDataReturnXmlFileHandlerTests.cs


注:本文中的ModelHelper.CreateDataReturnVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。