• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ModelHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: HandleAsync_CreatesUserWithStandardUserRole

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

                var user = helper.GetOrCreateUser("TestUser");
                user.Email = "[email protected]";

                database.Model.SaveChanges();

                var handler = new AddCompetentAuthorityUserHandler(database.WeeeContext, A.Dummy<ITestUserEmailDomains>());

                // Act
                var competentAuthorityUserId = await handler.HandleAsync(new AddCompetentAuthorityUser(user.Id));
                var competentAuthorityUser = domainHelper.GetCompetentAuthorityUser(competentAuthorityUserId);

                // Assert
                Assert.Equal(user.Id, competentAuthorityUser.UserId);
                Assert.NotNull(competentAuthorityUser.Role);
                Assert.Equal("InternalUser", competentAuthorityUser.Role.Name);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:25,代码来源:AddCompetentAuthorityUserHandlerTests.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: 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


示例4: 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


示例5: Fetch_ReturnsDataForSpecifiedComplianceYearOnly

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

                var scheme = helper.CreateScheme();
                var memberUpload1 = helper.CreateSubmittedMemberUpload(scheme);
                memberUpload1.ComplianceYear = 2016;

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

                var memberUpload2 = helper.CreateSubmittedMemberUpload(scheme);
                memberUpload2.ComplianceYear = 2017;
                var producer2 = helper.CreateProducerAsCompany(memberUpload2, "AAA");

                database.Model.SaveChanges();

                var dataAccess = new GetProducerDetailsDataAccess(database.WeeeContext);

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

                // Assert
                Assert.Single(result);
                Assert.Equal(2016, result.Single().RegisteredProducer.ComplianceYear);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:29,代码来源:GetProducerDetailsDataAccessTests.cs


示例6: using

        public async void GetOrganisationUsers_SameUserRejectedMultipleTimesForOneOrganisation_ButAlsoHasAnotherStatus_ReturnsTheOtherStatus(Core.Shared.UserStatus status)
        {
            using (var dbWrapper = new DatabaseWrapper())
            {
                // Add AspNet user user
                var modelHelper = new ModelHelper(dbWrapper.Model);
                var aspNetUser = modelHelper.CreateUser("My username", IdType.Guid);
                dbWrapper.Model.SaveChanges();

                // Add organisation
                var uniqueOrgName = "Test Org " + Guid.NewGuid();
                var country = dbWrapper.WeeeContext.Countries.First();
                var organisation = Domain.Organisation.Organisation.CreateSoleTrader(uniqueOrgName);
                organisation.AddOrUpdateMainContactPerson(new Domain.Organisation.Contact("First name", "Last name", "Developer"));
                organisation.AddOrUpdateAddress(AddressType.OrganisationAddress, new Domain.Organisation.Address(
                    "Address line 1",
                    string.Empty,
                    "Town",
                    string.Empty,
                    string.Empty,
                    country,
                    "01234567890",
                    "[email protected]"));
                organisation.CompleteRegistration();
                dbWrapper.WeeeContext.Organisations.Add(organisation);
                dbWrapper.WeeeContext.SaveChanges();

                // Add same organisation user multiple times, rejected
                var rejectedOrganisationUsers = new List<Domain.Organisation.OrganisationUser>
                {
                    new Domain.Organisation.OrganisationUser(Guid.Parse(aspNetUser.Id),
                        organisation.Id,
                        UserStatus.Rejected),
                    new Domain.Organisation.OrganisationUser(Guid.Parse(aspNetUser.Id),
                        organisation.Id,
                        UserStatus.Rejected),
                    new Domain.Organisation.OrganisationUser(Guid.Parse(aspNetUser.Id),
                        organisation.Id,
                        UserStatus.Rejected)
                };

                var otherOrganisationUser = new Domain.Organisation.OrganisationUser(Guid.Parse(aspNetUser.Id),
                    organisation.Id,
                    status.ToDomainEnumeration<UserStatus>());

                dbWrapper.WeeeContext.OrganisationUsers.AddRange(rejectedOrganisationUsers);
                dbWrapper.WeeeContext.OrganisationUsers.Add(otherOrganisationUser);
                dbWrapper.WeeeContext.SaveChanges();

                var dataAccess = new FindMatchingUsersDataAccess(dbWrapper.WeeeContext);

                var result = (await dataAccess.GetOrganisationUsers())
                    .Where(ou => ou.OrganisationName == uniqueOrgName);

                Assert.Single(result);

                var organisationUser = result.Single();
                Assert.Equal(status, organisationUser.Status);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:60,代码来源:FindMatchingUsersDataAccessTests.cs


示例7: 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


示例8: HandleAsync_XmlContainsSchemaError_StoresAvailableDataReturnData

        public async Task HandleAsync_XmlContainsSchemaError_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);

                database.Model.SaveChanges();

                var builder = new ProcessDataReturnXmlFileHandlerBuilder(database.WeeeContext);

                var xmlGeneratorResult = new GenerateFromDataReturnXmlResult<SchemeReturn>(
                    "Test XML string",
                    A.Dummy<SchemeReturn>(),
                    new List<XmlValidationError> { new XmlValidationError(ErrorLevel.Error, XmlErrorType.Schema, "Error text") });

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

                // 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.NotEqual(TimeSpan.Zero, dataReturnUpload.ProcessTime);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:35,代码来源:ProcessDataReturnXmlFileHandlerTests.cs


示例9: 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


示例10: 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


示例11: FetchSchemeInfo_WithValidOrganisationId_ReturnsScheme

        public async void FetchSchemeInfo_WithValidOrganisationId_ReturnsScheme()
        {
            using (var database = new DatabaseWrapper())
            {
                // Arrange
                Guid organisationId = Guid.NewGuid();
                ModelHelper modelHelper = new ModelHelper(database.Model);

                var scheme = modelHelper.CreateScheme();
                scheme.ApprovalNumber = "1234";
                scheme.Organisation.Id = organisationId;
                scheme.Organisation.TradingName = "TradingName";

                database.Model.SaveChanges();

                ProducerListFactoryDataAccess dataAccess = new ProducerListFactoryDataAccess(database.WeeeContext);

                // Act
                var result = await dataAccess.FetchSchemeInfo(organisationId);

                // Assert
                Assert.Equal("1234", result.First().ApprovalNumber);
                Assert.Equal("TradingName", result.First().TradingName);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:25,代码来源:ProducerListFactoryDataAccessTests.cs


示例12: GetLatestProducerEeeData_ReturnsData_WhenDataAvailableForSpecifiedScheme

        public async Task GetLatestProducerEeeData_ReturnsData_WhenDataAvailableForSpecifiedScheme()
        {
            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/MM0001AA");

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


示例13: 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


示例14: 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


示例15: Execute_ReturnsProducers_WithNonZeroChargesOnly

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

                var scheme = helper.CreateScheme();

                var invoiceRun = helper.CreateInvoiceRun();

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

                var producer1 = helper.CreateProducerAsCompany(memberUpload, "PRN123");
                producer1.ChargeThisUpdate = 0;
                producer1.Invoiced = true;

                var producer2 = helper.CreateProducerAsCompany(memberUpload, "PRN567");
                producer2.ChargeThisUpdate = 10;
                producer2.Invoiced = true;

                db.Model.SaveChanges();

                var result = await db.StoredProcedures.SpgInvoiceRunChargeBreakdown(invoiceRun.Id);

                Assert.Single(result);
                Assert.Equal("PRN567", result.Single().PRN);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:29,代码来源:SpgInvoiceRunChargeBreakdownTests.cs


示例16: using

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

                var scheme = modelHelper.CreateScheme();

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

                modelHelper.CreateProducerAsCompany(memberUpload, "1111", "B2B");

                var scheme2 = modelHelper.CreateScheme();

                var memberUpload2 = modelHelper.CreateSubmittedMemberUpload(scheme2);
                memberUpload2.ComplianceYear = 2016;

                modelHelper.CreateProducerAsCompany(memberUpload2, "1111", "B2C");

                database.Model.SaveChanges();

                StoredProcedures storedProcedures = new StoredProcedures(database.WeeeContext);

                // Act
                var result = await storedProcedures.SpgSubmissionChangesCsvData(memberUpload2.Id);

                // Assert
                Assert.Single(result);
                Assert.Equal("New", result[0].ChangeType);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:33,代码来源:SpgSubmissionChangesCsvDataTests.cs


示例17: GetComplianceYears_ReturnsComplianceYearForRegisteredProducer

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

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

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

                database.Model.SaveChanges();

                var dataAccess = new GetProducerComplianceYearDataAccess(database.WeeeContext);

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

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


示例18: 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


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ModelInterfaceExtenders类代码示例发布时间:2022-05-24
下一篇:
C# ModelElement类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap