Esempio n. 1
0
        public async Task TestGetDefaultExchangeVisitorFundingAsync_CheckAgenciesAndOrgs()
        {
            var govtAgency1 = new USGovernmentAgency {
                AgencyId    = 1,
                Description = "govtAgency1"
            };

            var govtAgency2 = new USGovernmentAgency {
                AgencyId    = 2,
                Description = "govtAgency2"
            };

            var intlOrg1 = new InternationalOrganization
            {
                OrganizationId = 1,
                Description    = "intlOrg1"
            };

            var intlOrg2 = new InternationalOrganization
            {
                OrganizationId = 2,
                Description    = "intlOrg2"
            };

            context.USGovernmentAgencies.Add(govtAgency1);
            context.USGovernmentAgencies.Add(govtAgency2);
            context.InternationalOrganizations.Add(intlOrg1);
            context.InternationalOrganizations.Add(intlOrg2);

            var model = new DefaultExchangeVisitorFunding
            {
                ProjectId            = 1,
                GovtAgency1Id        = govtAgency1.AgencyId,
                GovtAgency1          = govtAgency1,
                GovtAgency1OtherName = "govtAgency1OtherName",
                GovtAgency2Id        = govtAgency2.AgencyId,
                GovtAgency2          = govtAgency2,
                GovtAgency2OtherName = "govtAgency2OtherName",
                IntlOrg1Id           = intlOrg1.OrganizationId,
                IntlOrg1             = intlOrg1,
                IntlOrg1OtherName    = "intlOrg1OtherName",
                IntlOrg2Id           = intlOrg2.OrganizationId,
                IntlOrg2             = intlOrg2,
                IntlOrg2OtherName    = "intlOrg2OtherName"
            };

            context.DefaultExchangeVisitorFunding.Add(model);
            var result = await service.GetDefaultExchangeVisitorFundingAsync(model.ProjectId);

            Assert.AreEqual(govtAgency1.AgencyId, result.GovtAgency1Id);
            Assert.AreEqual(govtAgency1.Description, result.GovtAgency1Name);
            Assert.AreEqual(model.GovtAgency1OtherName, result.GovtAgency1OtherName);
            Assert.AreEqual(govtAgency2.AgencyId, result.GovtAgency2Id);
            Assert.AreEqual(govtAgency2.Description, result.GovtAgency2Name);
            Assert.AreEqual(model.GovtAgency2OtherName, result.GovtAgency2OtherName);
            Assert.AreEqual(intlOrg1.OrganizationId, result.IntlOrg1Id);
            Assert.AreEqual(intlOrg1.Description, result.IntlOrg1Name);
            Assert.AreEqual(model.IntlOrg1OtherName, result.IntlOrg1OtherName);
            Assert.AreEqual(intlOrg2.OrganizationId, result.IntlOrg2Id);
            Assert.AreEqual(intlOrg2.Description, result.IntlOrg2Name);
            Assert.AreEqual(model.IntlOrg2OtherName, result.IntlOrg2OtherName);
        }
Esempio n. 2
0
        public void TestCreateGetParticipantExchangeVisitorsDTOQuery_CheckProperties()
        {
            var project = new Project
            {
                ProjectId = 100
            };
            var participant = new Participant
            {
                ParticipantId = 2,
                ProjectId     = project.ProjectId,
                Project       = project
            };
            var fieldOfStudy = new FieldOfStudy
            {
                FieldOfStudyId = 3,
                Description    = "field of study",
            };
            var programCategory = new ProgramCategory
            {
                ProgramCategoryId   = 3,
                Description         = "program category",
                ProgramCategoryCode = "pccode"
            };
            var position = new Position
            {
                PositionId   = 4,
                Description  = "position",
                PositionCode = "positioncode"
            };
            var usGovAgency1 = new USGovernmentAgency
            {
                AgencyCode  = "usgovcode1",
                AgencyId    = 5,
                Description = "us gov agency1",
            };
            var usGovAgency2 = new USGovernmentAgency
            {
                AgencyCode  = "usgovcode2",
                AgencyId    = 6,
                Description = "us gov agency2",
            };

            var internationalOrg1 = new InternationalOrganization
            {
                Description      = "int org 1",
                OrganizationCode = "int org 1 code",
                OrganizationId   = 7,
            };
            var internationalOrg2 = new InternationalOrganization
            {
                Description      = "int org 2",
                OrganizationCode = "int org 2 code",
                OrganizationId   = 8,
            };
            var visitor = new ParticipantExchangeVisitor
            {
                ParticipantId        = participant.ParticipantId,
                Participant          = participant,
                FieldOfStudy         = fieldOfStudy,
                FieldOfStudyId       = fieldOfStudy.FieldOfStudyId,
                FundingGovtAgency1   = 2.0m,
                FundingGovtAgency2   = 3.0m,
                FundingIntlOrg1      = 4.0m,
                FundingIntlOrg2      = 5.0m,
                FundingOther         = 6.0m,
                FundingPersonal      = 7.0m,
                FundingSponsor       = 8.0m,
                FundingTotal         = 9.0m,
                FundingVisBNC        = 10.0m,
                FundingVisGovt       = 11.0m,
                GovtAgency1          = usGovAgency1,
                GovtAgency1Id        = usGovAgency1.AgencyId,
                GovtAgency1OtherName = "other name",
                GovtAgency2          = usGovAgency2,
                GovtAgency2Id        = usGovAgency2.AgencyId,
                GovtAgency2OtherName = "other other name",
                IntlOrg1             = internationalOrg1,
                IntlOrg1Id           = internationalOrg1.OrganizationId,
                IntlOrg1OtherName    = "other other other name",
                IntlOrg2             = internationalOrg2,
                IntlOrg2Id           = internationalOrg2.OrganizationId,
                IntlOrg2OtherName    = "other name 2",
                OtherName            = "other name again",
                ProgramCategory      = programCategory,
                ProgramCategoryId    = programCategory.ProgramCategoryId,
                Position             = position,
                PositionId           = position.PositionId
            };

            context.Projects.Add(project);
            context.Participants.Add(participant);
            context.FieldOfStudies.Add(fieldOfStudy);
            context.ProgramCategories.Add(programCategory);
            context.Positions.Add(position);
            context.ParticipantExchangeVisitors.Add(visitor);
            context.USGovernmentAgencies.Add(usGovAgency1);
            context.USGovernmentAgencies.Add(usGovAgency2);
            context.InternationalOrganizations.Add(internationalOrg1);
            context.InternationalOrganizations.Add(internationalOrg2);

            Action <ParticipantExchangeVisitorDTO> tester = (result) =>
            {
                Assert.AreEqual(project.ProjectId, result.ProjectId);
                Assert.AreEqual(participant.ParticipantId, result.ParticipantId);
                Assert.AreEqual(visitor.FundingGovtAgency1, result.FundingGovtAgency1);
                Assert.AreEqual(visitor.FundingGovtAgency2, result.FundingGovtAgency2);
                Assert.AreEqual(visitor.FundingIntlOrg1, result.FundingIntlOrg1);
                Assert.AreEqual(visitor.FundingIntlOrg2, result.FundingIntlOrg2);
                Assert.AreEqual(visitor.FundingOther, result.FundingOther);
                Assert.AreEqual(visitor.FundingPersonal, result.FundingPersonal);
                Assert.AreEqual(visitor.FundingSponsor, result.FundingSponsor);
                Assert.AreEqual(visitor.FundingTotal, result.FundingTotal);
                Assert.AreEqual(visitor.FundingVisBNC, result.FundingVisBNC);
                Assert.AreEqual(visitor.FundingVisGovt, result.FundingVisGovt);
                Assert.AreEqual(visitor.GovtAgency1OtherName, result.GovtAgency1OtherName);
                Assert.AreEqual(visitor.GovtAgency2OtherName, result.GovtAgency2OtherName);
                Assert.AreEqual(visitor.IntlOrg1OtherName, result.IntlOrg1OtherName);
                Assert.AreEqual(visitor.IntlOrg2OtherName, result.IntlOrg2OtherName);
                Assert.AreEqual(visitor.OtherName, result.OtherName);

                Assert.AreEqual(visitor.FieldOfStudyId, result.FieldOfStudyId);
                Assert.AreEqual(fieldOfStudy.Description, result.FieldOfStudy);

                Assert.AreEqual(visitor.GovtAgency1Id, result.GovtAgency1Id);
                Assert.AreEqual(usGovAgency1.Description, result.GovtAgency1Name);

                Assert.AreEqual(visitor.GovtAgency2Id, result.GovtAgency2Id);
                Assert.AreEqual(usGovAgency2.Description, result.GovtAgency2Name);

                Assert.AreEqual(visitor.ProgramCategoryId, result.ProgramCategoryId);
                Assert.AreEqual(programCategory.Description, result.ProgramCategory);
                Assert.AreEqual(programCategory.ProgramCategoryCode, result.ProgramCategoryCode);

                Assert.AreEqual(visitor.IntlOrg1Id, result.IntlOrg1Id);
                Assert.AreEqual(internationalOrg1.Description, result.IntlOrg1Name);

                Assert.AreEqual(visitor.IntlOrg2Id, result.IntlOrg2Id);
                Assert.AreEqual(internationalOrg2.Description, result.IntlOrg2Name);

                Assert.AreEqual(visitor.PositionId, result.PositionId);
                Assert.AreEqual(visitor.Position.Description, result.Position);
                Assert.AreEqual(position.PositionCode, result.PositionCode);
            };

            var queryResult = ParticipantExchangeVisitorQueries.CreateGetParticipantExchangeVisitorsDTOQuery(context).ToList();

            Assert.AreEqual(1, queryResult.Count());
            tester(queryResult.First());
        }
Esempio n. 3
0
        public async Task TestUpdateAsync_CheckProperties()
        {
            var govtAgency1 = new USGovernmentAgency
            {
                AgencyId    = 1,
                Description = "govtAgency1"
            };

            var govtAgency2 = new USGovernmentAgency
            {
                AgencyId    = 2,
                Description = "govtAgency2"
            };

            context.USGovernmentAgencies.Add(govtAgency1);
            context.USGovernmentAgencies.Add(govtAgency2);

            var intlOrg1 = new InternationalOrganization
            {
                OrganizationId = 1,
                Description    = "intlOrg1"
            };

            var intlOrg2 = new InternationalOrganization
            {
                OrganizationId = 2,
                Description    = "intlOrg2"
            };

            context.InternationalOrganizations.Add(intlOrg1);
            context.InternationalOrganizations.Add(intlOrg2);

            var initialExchangeVisitorFunding = new DefaultExchangeVisitorFunding
            {
                ProjectId          = 1,
                FundingSponsor     = 0,
                FundingPersonal    = 0,
                FundingVisGovt     = 0,
                FundingVisBNC      = 0,
                FundingGovtAgency1 = 0,
                FundingGovtAgency2 = 0,
                FundingIntlOrg1    = 0,
                FundingIntlOrg2    = 0,
                FundingOther       = 0,
                FundingTotal       = 0
            };

            context.DefaultExchangeVisitorFunding.Add(initialExchangeVisitorFunding);

            var updatedDefaultExchangeVisitorFunding = new UpdatedDefaultExchangeVisitorFunding(
                new Business.Service.User(1),
                1,
                2,
                3,
                4,
                5,
                6,
                govtAgency1.AgencyId,
                "Govt Agency 1",
                7,
                govtAgency2.AgencyId,
                "Govt Agency 2",
                8,
                intlOrg1.OrganizationId,
                "Intl Org 1",
                9,
                intlOrg2.OrganizationId,
                "Intl Org 2",
                10,
                "Other Name",
                55);

            await service.UpdateAsync(updatedDefaultExchangeVisitorFunding);

            var defaultExchangeVisitorFunding = context.DefaultExchangeVisitorFunding.Find(initialExchangeVisitorFunding.ProjectId);

            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.ProjectId, defaultExchangeVisitorFunding.ProjectId);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.FundingSponsor, defaultExchangeVisitorFunding.FundingSponsor);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.FundingPersonal, defaultExchangeVisitorFunding.FundingPersonal);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.FundingVisGovt, defaultExchangeVisitorFunding.FundingVisGovt);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.FundingVisBNC, defaultExchangeVisitorFunding.FundingVisBNC);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.FundingGovtAgency1, defaultExchangeVisitorFunding.FundingGovtAgency1);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.FundingGovtAgency2, defaultExchangeVisitorFunding.FundingGovtAgency2);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.FundingIntlOrg1, defaultExchangeVisitorFunding.FundingIntlOrg1);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.FundingIntlOrg2, defaultExchangeVisitorFunding.FundingIntlOrg2);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.FundingOther, defaultExchangeVisitorFunding.FundingOther);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.FundingTotal, defaultExchangeVisitorFunding.FundingTotal);

            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.GovtAgency1OtherName, defaultExchangeVisitorFunding.GovtAgency1OtherName);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.GovtAgency2OtherName, defaultExchangeVisitorFunding.GovtAgency2OtherName);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.IntlOrg1OtherName, defaultExchangeVisitorFunding.IntlOrg1OtherName);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.IntlOrg2OtherName, defaultExchangeVisitorFunding.IntlOrg2OtherName);
            Assert.AreEqual(updatedDefaultExchangeVisitorFunding.OtherName, defaultExchangeVisitorFunding.OtherName);

            Assert.AreEqual(govtAgency1.AgencyId, defaultExchangeVisitorFunding.GovtAgency1Id);
            Assert.AreEqual(govtAgency2.AgencyId, defaultExchangeVisitorFunding.GovtAgency2Id);
            Assert.AreEqual(intlOrg1.OrganizationId, defaultExchangeVisitorFunding.IntlOrg1Id);
            Assert.AreEqual(intlOrg2.OrganizationId, defaultExchangeVisitorFunding.IntlOrg2Id);
        }