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


C# ModelHelper.CreateMemberUpload方法代码示例

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


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

示例1: FetchSumissions_ForYearandScheme_ReturnsSubmittedSubmissions

        public async Task FetchSumissions_ForYearandScheme_ReturnsSubmittedSubmissions()
        {
            using (DatabaseWrapper database = new DatabaseWrapper())
            {
                ModelHelper helper = new ModelHelper(database.Model);

                // Arrange
                Scheme scheme1 = helper.CreateScheme();
                Scheme scheme2 = helper.CreateScheme();

                var user1 = helper.CreateUser("[email protected]");
                var user2 = helper.CreateUser("[email protected]");

                MemberUpload memberUpload1 = helper.CreateMemberUpload(scheme1);
                memberUpload1.ComplianceYear = 2005;
                memberUpload1.IsSubmitted = true;
                memberUpload1.SubmittedDate = new DateTime(2015, 09, 22, 10, 45, 45);
                memberUpload1.SubmittedByUserId = user1.Id;

                MemberUpload memberUpload2 = helper.CreateMemberUpload(scheme1);
                memberUpload2.ComplianceYear = 2006;
                memberUpload2.IsSubmitted = true;
                memberUpload2.SubmittedDate = new DateTime(2015, 08, 10, 12, 25, 35);
                memberUpload2.SubmittedByUserId = user1.Id;

                MemberUpload memberUpload3 = helper.CreateMemberUpload(scheme1);
                memberUpload3.ComplianceYear = 2006;
                memberUpload3.IsSubmitted = false;
                memberUpload3.SubmittedDate = new DateTime(2015, 09, 10, 12, 25, 35);
                memberUpload3.SubmittedByUserId = user1.Id;

                MemberUpload memberUpload4 = helper.CreateMemberUpload(scheme2);
                memberUpload4.ComplianceYear = 2006;
                memberUpload4.IsSubmitted = true;
                memberUpload4.SubmittedDate = new DateTime(2015, 07, 22, 10, 45, 45);
                memberUpload4.SubmittedByUserId = user2.Id;

                database.Model.SaveChanges();

                // Act
                GetSubmissionsHistoryResultsDataAccess dataAccess =
                    new GetSubmissionsHistoryResultsDataAccess(database.WeeeContext);
                var results = await dataAccess.GetSubmissionsHistory(scheme1.Id, 2006);

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

                var result1 = results.Data.SingleOrDefault(r => r.Year == 2006);
                Assert.NotNull(result1);
                Assert.Equal("08/10/2015 12:25:35", result1.DateTime.ToString(CultureInfo.InvariantCulture));
                Assert.Equal("Test LastName", result1.SubmittedBy);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:54,代码来源:GetSubmissionsHistoryResultsDataAccessTests.cs

示例2: using

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

                var scheme = helper.CreateScheme();
                string registrationNumber = "AAAA";
                int complianceYear = 2016;

                var registeredProducer = helper.GetOrCreateRegisteredProducer(scheme, complianceYear, registrationNumber);

                var memberUpload = helper.CreateMemberUpload(scheme);
                memberUpload.ComplianceYear = complianceYear;
                memberUpload.IsSubmitted = false;

                var producerSubmission = helper.CreateProducerAsCompany(memberUpload, registrationNumber);

                // At least one user is required in the database.
                helper.GetOrCreateUser("A user");

                database.Model.SaveChanges();

                User user = await database.WeeeContext.Users.FirstAsync();
                IDomainUserContext domainUserContext = A.Fake<IDomainUserContext>();
                A.CallTo(() => domainUserContext.GetCurrentUserAsync()).Returns(user);

                var handler = new MemberUploadSubmissionHandler(A.Dummy<IWeeeAuthorization>(), database.WeeeContext, domainUserContext);
                await handler.HandleAsync(new MemberUploadSubmission(scheme.OrganisationId, memberUpload.Id));

                var registeredProducerDb = FindRegisteredProducer(database, registeredProducer.Id);

                Assert.Equal(registeredProducerDb.CurrentSubmission.Id, producerSubmission.Id);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:35,代码来源:MemberUploadSubmissionHandlerTests.cs

示例3: Execute_HappyPath_ReturnsProducerWithSelectedSchemeandAA

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

                Scheme scheme1 = helper.CreateScheme();

                scheme1.CompetentAuthorityId = new Guid("4EEE5942-01B2-4A4D-855A-34DEE1BBBF26");

                MemberUpload memberUpload1 = helper.CreateMemberUpload(scheme1);
                memberUpload1.ComplianceYear = 2016;
                memberUpload1.IsSubmitted = true;
                memberUpload1.SubmittedDate = new DateTime(2015, 1, 1);

                ProducerSubmission producer1 = helper.CreateProducerAsCompany(memberUpload1, "WEE/11AAAA11");

                db.Model.SaveChanges();

                // Act
                List<MembersDetailsCsvData> results =
                    await db.StoredProcedures.SpgCSVDataBySchemeComplianceYearAndAuthorisedAuthority(2016, false,
                        false, scheme1.Id, scheme1.CompetentAuthorityId);

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

                MembersDetailsCsvData result = results[0];

                Assert.Equal("WEE/11AAAA11", result.PRN);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:34,代码来源:SpgCSVDataBySchemeComplianceYearAndAuthorisedAuthorityTests.cs

示例4: Execute_WithNonSubmittedMemberUpload_IgnoresProducer

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

                Scheme scheme1 = helper.CreateScheme();

                MemberUpload memberUpload1 = helper.CreateMemberUpload(scheme1);
                memberUpload1.ComplianceYear = 2016;
                memberUpload1.IsSubmitted = false;

                helper.CreateProducerAsCompany(memberUpload1, "WEE/11AAAA11");

                db.Model.SaveChanges();

                // Act
                List<MembersDetailsCsvData> results = await db.StoredProcedures.SpgCSVDataBySchemeComplianceYearAndAuthorisedAuthority(2016, false, false, scheme1.Id, null);

                // Assert
                Assert.NotNull(results);
                Assert.Equal(0, results.Count);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:25,代码来源:SpgCSVDataBySchemeComplianceYearAndAuthorisedAuthorityTests.cs

示例5: using

        public async void GetComplianceYearsWithSubmittedMemberUploads_SchemeHasSubmittedMemberUpload_ReturnsCorrespondingComplianceYear()
        {
            const int complianceYear = 1923;

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

                var scheme = modelHelper.CreateScheme();
                var memberUpload = modelHelper.CreateMemberUpload(scheme);

                memberUpload.IsSubmitted = true;
                memberUpload.ComplianceYear = complianceYear;

                await databaseWrapper.Model.SaveChangesAsync();

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

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

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

示例6: Fetch_ReturnsDataForSubmittedProducerOnly

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

                var scheme = helper.CreateScheme();
                var memberUpload = helper.CreateMemberUpload(scheme);
                memberUpload.ComplianceYear = 2016;
                memberUpload.IsSubmitted = false;

                var producer = helper.CreateProducerAsCompany(memberUpload, "AAA");

                database.Model.SaveChanges();

                var dataAccess = new GetProducerDetailsDataAccess(database.WeeeContext);

                // Act
                var result = await dataAccess.Fetch("AAA", 2016);

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

示例7: GetComplianceYears_DoesNotReturnUnsubmittedUploads

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

                var scheme = helper.CreateScheme();
                var memberUpload = helper.CreateMemberUpload(scheme);
                memberUpload.ComplianceYear = 2016;
                memberUpload.IsSubmitted = false;

                var producer1 = helper.CreateProducerAsCompany(memberUpload, "AAA");

                database.Model.SaveChanges();

                var dataAccess = new GetProducerComplianceYearDataAccess(database.WeeeContext);

                // Act
                var result = await dataAccess.GetComplianceYears("AAA");

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

示例8: GetSubmissionHistory_WitValidSchemeIdAndYear2015_ReturnsOnly2015YearSubmissionHistoryData

        public async void GetSubmissionHistory_WitValidSchemeIdAndYear2015_ReturnsOnly2015YearSubmissionHistoryData()
        {
            using (var database = new DatabaseWrapper())
            {
                Guid organisationId = new Guid("72BB14DF-DCD5-4DBB-BBA9-4CFC26AD80F9");
                GetSubmissionsHistoryResultsDataAccess dataAccess = new GetSubmissionsHistoryResultsDataAccess(database.WeeeContext);

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

                var user1 = modelHelper.CreateUser("Test");
                database.Model.SaveChanges();

                var scheme1 = modelHelper.CreateScheme();
                scheme1.Organisation.Id = organisationId;
                database.Model.SaveChanges();

                var mu1 = modelHelper.CreateMemberUpload(scheme1);
                mu1.ComplianceYear = 2015;
                mu1.IsSubmitted = true;
                mu1.SubmittedDate = new DateTime(2015, 1, 1);

                var mu2 = modelHelper.CreateMemberUpload(scheme1);
                mu2.ComplianceYear = 2015;
                mu2.IsSubmitted = true;
                mu2.SubmittedDate = new DateTime(2015, 1, 1);

                var mu3 = modelHelper.CreateMemberUpload(scheme1);
                mu3.ComplianceYear = 2016;
                mu3.IsSubmitted = true;
                mu3.SubmittedDate = new DateTime(2015, 1, 1);

                database.Model.SaveChanges();

                // Act
                var result = await dataAccess.GetSubmissionsHistory(scheme1.Id, 2015);

                // Assert
                Assert.NotNull(result.Data);
                Assert.Equal(2, result.Data.Count);
                Assert.Collection(result.Data,
                                  r1 => Assert.Equal(r1.Year, 2015),
                                  r2 => Assert.Equal(r2.Year, 2015));
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:45,代码来源:GetSubmissionHistoryDataAccessTests.cs

示例9: HappyPath_ManyUniquePrnsGeneratedAndSeedUpdatedToExpectedValue

        public async Task HappyPath_ManyUniquePrnsGeneratedAndSeedUpdatedToExpectedValue()
        {
            // arrange
            var validXmlLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase), @"ExampleXML\v3-valid-many-insertions.xml");
            var validXmlString = File.ReadAllText(new Uri(validXmlLocation).LocalPath);
            var validXmlBytes = File.ReadAllBytes(new Uri(validXmlLocation).LocalPath);

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

                var org = modelHelper.CreateOrganisation();
                var scheme = modelHelper.CreateScheme(org);
                var memberUpload = modelHelper.CreateMemberUpload(scheme);

                var message = new ProcessXmlFile(org.Id, validXmlBytes, "File name");

                var initialSeed = database.WeeeContext.SystemData.Select(sd => sd.LatestPrnSeed).First();
                var expectedSeed = ExpectedSeedAfterThisXml(validXmlString, initialSeed);

                var whiteSpaceCollapser = A.Fake<IWhiteSpaceCollapser>();

                var xmlConverter = new XmlConverter(whiteSpaceCollapser, new Deserializer());
                var schemeType = xmlConverter.Deserialize<schemeType>(xmlConverter.Convert(message.Data));

                var producerCharges = new Dictionary<string, ProducerCharge>();
                var anyAmount = 30;
                var anyChargeBandAmount = A.Dummy<ChargeBandAmount>();

                foreach (var producerData in schemeType.producerList)
                {
                    var producerName = producerData.GetProducerName();
                    if (!producerCharges.ContainsKey(producerName))
                    {
                        producerCharges.Add(producerName,
                            new ProducerCharge { Amount = anyAmount, ChargeBandAmount = anyChargeBandAmount });
                    }
                }

                database.Model.SaveChanges();

                var contextMemberUpload = database.WeeeContext.MemberUploads
                    .Single(mu => mu.Id == memberUpload.Id);

                // act
                var producers = await new GenerateFromXml(
                    xmlConverter,
                    new GenerateFromXmlDataAccess(database.WeeeContext)).GenerateProducers(message, contextMemberUpload, producerCharges);

                // assert
                long newSeed = database.WeeeContext.SystemData.Select(sd => sd.LatestPrnSeed).First();
                Assert.Equal(expectedSeed, newSeed);

                var prns = producers.Select(p => p.RegisteredProducer.ProducerRegistrationNumber);
                Assert.Equal(prns.Distinct(), prns); // all prns should be unique
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:57,代码来源:PrnGenerationIntegration.cs

示例10: Get_TwoUploadsForTheSameComplianceYear_OnlyReturnsTheYearOnce

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

                // 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 firstMemberUpload = modelHelper.CreateMemberUpload(scheme);

                firstMemberUpload.ComplianceYear = complianceYear;
                firstMemberUpload.IsSubmitted = true;
                firstMemberUpload.OrganisationId = organisation.Id;
                firstMemberUpload.CreatedDate = DateTime.Now;
                firstMemberUpload.CreatedById = database.WeeeContext.GetCurrentUser();

                var secondMemberUpload = modelHelper.CreateMemberUpload(scheme);

                secondMemberUpload.ComplianceYear = complianceYear;
                secondMemberUpload.IsSubmitted = true;
                secondMemberUpload.OrganisationId = organisation.Id;
                secondMemberUpload.CreatedDate = DateTime.Now;
                secondMemberUpload.CreatedById = database.WeeeContext.GetCurrentUser();

                await database.Model.SaveChangesAsync();

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

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

示例11: GetRegistrationNumbers_ReturnsRegistrationNumbers

        public async void GetRegistrationNumbers_ReturnsRegistrationNumbers()
        {
            using (var database = new DatabaseWrapper())
            {
                // Arrange
                ModelHelper modelHelper = new ModelHelper(database.Model);

                int complianceYear = 2015;

                Guid organisationId = Guid.NewGuid();
                var scheme = modelHelper.CreateScheme();
                scheme.Organisation.Id = organisationId;

                var memberUpload1 = modelHelper.CreateMemberUpload(scheme);
                memberUpload1.ComplianceYear = complianceYear;
                memberUpload1.IsSubmitted = true;

                modelHelper.GetOrCreateRegisteredProducer(scheme, complianceYear, "1234");
                modelHelper.CreateProducerAsCompany(memberUpload1, "1234");

                var memberUpload2 = modelHelper.CreateMemberUpload(scheme);
                memberUpload2.ComplianceYear = complianceYear;
                memberUpload2.IsSubmitted = true;

                modelHelper.GetOrCreateRegisteredProducer(scheme, complianceYear, "987");
                modelHelper.CreateProducerAsCompany(memberUpload2, "987");

                database.Model.SaveChanges();

                ProducerListFactoryDataAccess dataAccess = new ProducerListFactoryDataAccess(database.WeeeContext);

                // Act
                var result = await dataAccess.GetRegistrationNumbers(organisationId, complianceYear, 2);

                // Assert
                Assert.Equal(2, result.Count);
                Assert.Contains("1234", result);
                Assert.Contains("987", result);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:40,代码来源:ProducerListFactoryDataAccessTests.cs

示例12: GetComplianceYearsWithSubmittedMemberUploads_SchemeHasUnsubmittedMemberUpload_ReturnsNoYears

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

                var scheme = modelHelper.CreateScheme();
                var memberUpload = modelHelper.CreateMemberUpload(scheme);

                memberUpload.IsSubmitted = false;

                await databaseWrapper.Model.SaveChangesAsync();

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

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

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

示例13: Execute_ListOfProducers_ReturnsRecordsInCurrectOrder

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

                Scheme scheme1 = helper.CreateScheme();

                scheme1.OrganisationId = new Guid("4EEE5942-01B2-4A4D-855A-34DEE1BBBF26");
                scheme1.Organisation.Id = new Guid("4EEE5942-01B2-4A4D-855A-34DEE1BBBF26");
                scheme1.SchemeName = "Lamborghini";

                scheme1.Organisation.Name = "PCS operator name";
                scheme1.Organisation.BusinessAddressId = new Guid("b58e9cb2-b97e-4141-ad32-73c70284fc77");
                scheme1.Organisation.Address = helper.CreateOrganisationAddress();
                scheme1.Organisation.Address.Id = new Guid("b58e9cb2-b97e-4141-ad32-73c70284fc77");

                MemberUpload memberUpload1 = helper.CreateMemberUpload(scheme1);
                memberUpload1.ComplianceYear = 2016;
                memberUpload1.IsSubmitted = true;

                ProducerSubmission producerSubmission1 = helper.CreateProducerAsCompany(memberUpload1, "WEE/99ZZZZ99");
                producerSubmission1.Business.Company.Name = "A company name";

                ProducerSubmission producerSubmission2 = helper.CreateProducerAsCompany(memberUpload1, "WEE/88ZZZZ88");
                producerSubmission2.Business.Company.Name = "B company name";

                Scheme scheme2 = helper.CreateScheme();

                scheme2.OrganisationId = new Guid("84729d95-3c26-4c37-9730-f25fa2b6dbfc");
                scheme2.Organisation.Id = new Guid("84729d95-3c26-4c37-9730-f25fa2b6dbfc");
                scheme2.SchemeName = "Aston Martin";

                scheme2.Organisation.Name = "PCS operator name 1";
                scheme2.Organisation.BusinessAddressId = new Guid("ecdf60fc-1576-43e2-9bb4-e6c9dc9d721d");
                scheme2.Organisation.Address = helper.CreateOrganisationAddress();
                scheme2.Organisation.Address.Id = new Guid("ecdf60fc-1576-43e2-9bb4-e6c9dc9d721d");

                MemberUpload memberUpload2 = helper.CreateMemberUpload(scheme2);
                memberUpload2.ComplianceYear = 2016;
                memberUpload2.IsSubmitted = true;

                ProducerSubmission producerSubmission3 = helper.CreateProducerAsCompany(memberUpload2, "WEE/11ZZZZ11");
                producerSubmission3.Business.Company.Name = "C company name";

                ProducerSubmission producerSubmission4 = helper.CreateProducerAsCompany(memberUpload2, "WEE/22ZZZZ22");
                producerSubmission4.Business.Company.Name = "D company name";

                db.Model.SaveChanges();

                // Act
                List<ProducerPublicRegisterCSVData> results =
                    await db.StoredProcedures.SpgProducerPublicRegisterCSVDataByComplianceYear(2016);

                // Assert
                Assert.NotNull(results);
                Assert.True(results.FindIndex(i => i.SchemeName == "Aston Martin" && i.ProducerName == "C company name") < results.FindIndex(i => i.SchemeName == "Aston Martin" && i.ProducerName == "D company name"));
                Assert.True(results.FindIndex(i => i.SchemeName == "Lamborghini" && i.ProducerName == "A company name") < results.FindIndex(i => i.SchemeName == "Lamborghini" && i.ProducerName == "B company name"));
                Assert.True(results.FindIndex(i => i.SchemeName == "Aston Martin" && i.ProducerName == "C company name") < results.FindIndex(i => i.SchemeName == "Lamborghini" && i.ProducerName == "B company name"));
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:62,代码来源:SpgProducerPublicRegisterCSVDataByComplianceYearTests.cs

示例14: Execute_ProducerTypeIsPartnership_ReturnsPartnershipNameAsProducerName

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

                Scheme scheme1 = helper.CreateScheme();

                scheme1.OrganisationId = new Guid("4EEE5942-01B2-4A4D-855A-34DEE1BBBF26");
                scheme1.Organisation.Id = new Guid("4EEE5942-01B2-4A4D-855A-34DEE1BBBF26");

                scheme1.Organisation.BusinessAddressId = new Guid("b58e9cb2-b97e-4141-ad32-73c70284fc77");
                scheme1.Organisation.Address = helper.CreateOrganisationAddress();
                scheme1.Organisation.Address.Id = new Guid("b58e9cb2-b97e-4141-ad32-73c70284fc77");

                MemberUpload memberUpload1 = helper.CreateMemberUpload(scheme1);
                memberUpload1.ComplianceYear = 2016;
                memberUpload1.IsSubmitted = true;

                ProducerSubmission producerSubmission = helper.CreateProducerAsPartnership(memberUpload1, "WEE/99ZZZZ99");

                db.Model.SaveChanges();

                // Act
                List<ProducerPublicRegisterCSVData> results =
                   await db.StoredProcedures.SpgProducerPublicRegisterCSVDataByComplianceYear(2016);

                // Assert
                var result = results.SingleOrDefault(i => i.PRN == "WEE/99ZZZZ99");

                Assert.NotNull(result);
                Assert.Equal(result.ProducerName, producerSubmission.Business.Partnership.Name);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:35,代码来源:SpgProducerPublicRegisterCSVDataByComplianceYearTests.cs

示例15: using

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

                Scheme scheme1 = helper.CreateScheme();

                scheme1.OrganisationId = new Guid("4EEE5942-01B2-4A4D-855A-34DEE1BBBF26");
                scheme1.Organisation.Id = new Guid("4EEE5942-01B2-4A4D-855A-34DEE1BBBF26");
                scheme1.SchemeName = "SchemeName";
                
                scheme1.Organisation.Name = "PCS operator name";
                scheme1.Organisation.BusinessAddressId = new Guid("b58e9cb2-b97e-4141-ad32-73c70284fc77");
                scheme1.Organisation.Address = helper.CreateOrganisationAddress();
                scheme1.Organisation.Address.Id = new Guid("b58e9cb2-b97e-4141-ad32-73c70284fc77");

                MemberUpload memberUpload1 = helper.CreateMemberUpload(scheme1);
                memberUpload1.ComplianceYear = 2016;
                memberUpload1.IsSubmitted = true;
                
                ProducerSubmission producerSubmission1 = helper.CreateProducerAsCompany(memberUpload1, "WEE/99ZZZZ99");
                producerSubmission1.Business.Company.Contact1.Telephone = "55 5555 5555";
                producerSubmission1.Business.Company.Contact1.Email = "[email protected]";

                Scheme scheme2 = helper.CreateScheme();

                scheme2.OrganisationId = new Guid("84729d95-3c26-4c37-9730-f25fa2b6dbfc");
                scheme2.Organisation.Id = new Guid("84729d95-3c26-4c37-9730-f25fa2b6dbfc");
                scheme2.SchemeName = "A test scheme name";

                scheme2.Organisation.Name = "PCS operator name 1";
                scheme2.Organisation.BusinessAddressId = new Guid("ecdf60fc-1576-43e2-9bb4-e6c9dc9d721d");
                scheme2.Organisation.Address = helper.CreateOrganisationAddress();
                scheme2.Organisation.Address.Id = new Guid("ecdf60fc-1576-43e2-9bb4-e6c9dc9d721d");

                MemberUpload memberUpload2 = helper.CreateMemberUpload(scheme2);
                memberUpload2.ComplianceYear = 2017;
                memberUpload2.IsSubmitted = true;

                ProducerSubmission producerSubmission2 = helper.CreateProducerAsCompany(memberUpload2, "WEE/11ZZZZ11");
                producerSubmission2.Business.Company.Contact1.Telephone = "55 5555 5555";
                producerSubmission2.Business.Company.Contact1.Email = "[email protected]";

                db.Model.SaveChanges();

                // Act
                List<ProducerPublicRegisterCSVData> results =
                    await db.StoredProcedures.SpgProducerPublicRegisterCSVDataByComplianceYear(2016);

                // Assert
                Assert.NotNull(results);
                Assert.True(results.TrueForAll(i => i.ComplianceYear == 2016));

                Assert.False(results.Any(i => i.PRN == "WEE/11ZZZZ11" && i.ComplianceYear == 2017));

                var result = results.SingleOrDefault(i => i.PRN == "WEE/99ZZZZ99" && i.ComplianceYear == 2016);

                Assert.NotNull(result);
                Assert.Equal(result.CSROAAddress1, scheme1.Organisation.Address.Address1);
                Assert.Equal(result.CSROAPostcode, scheme1.Organisation.Address.Postcode);

                Assert.Equal(result.SchemeName, scheme1.SchemeName);
                Assert.Equal(result.SchemeOperator, scheme1.Organisation.Name);

                Assert.Equal(result.ROATelephone, producerSubmission1.Business.Company.Contact1.Telephone);
                Assert.Equal(result.ROAEmail, producerSubmission1.Business.Company.Contact1.Email);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:70,代码来源:SpgProducerPublicRegisterCSVDataByComplianceYearTests.cs


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