public void TestProgramSponsor_ContainsCharacters()
        {
            var otherFunds                    = new OtherFunds("10", null, null, null, null, null);
            var programSponsorFunds           = "100";
            var receivedUsGovtFunds           = true;
            var printForm                     = true;
            Func <FinancialInfo> createEntity = () =>
            {
                var financialInfo = new FinancialInfo(
                    printForm: printForm,
                    receivedUSGovtFunds: receivedUsGovtFunds,
                    programSponsorFunds: programSponsorFunds,
                    otherFunds: otherFunds);
                return(financialInfo);
            };

            var validator = new FinancialInfoValidator();
            var instance  = createEntity();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            programSponsorFunds = "c";
            instance            = createEntity();
            result = validator.Validate(instance);
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(1, result.Errors.Count);
            Assert.AreEqual(FinancialInfoValidator.PROGRAM_SPONSOR_FUNDS_ERROR_MESSAGE, result.Errors.First().ErrorMessage);
            Assert.IsInstanceOfType(result.Errors.First().CustomState, typeof(FundingErrorPath));
        }
Ejemplo n.º 2
0
        public void TestConstructor()
        {
            var binationalCommission = "commission";
            var personal             = "peronsal";
            var evGovt        = "ev gov";
            var other         = new Other("name", "amount");
            var usGovt        = new USGovernmentFunding("us gov 1", null, "us gov value 1", null, null, null);
            var international = new InternationalFunding("international org 1", null, "internation org 1 value", null, null, null);
            var instance      = new OtherFunds(evGovt, binationalCommission, personal, usGovt, international, other);

            Assert.AreEqual(binationalCommission, instance.BinationalCommission);
            Assert.AreEqual(personal, instance.Personal);
            Assert.AreEqual(evGovt, instance.ExchangeVisitorGovernment);
            Assert.IsTrue(Object.ReferenceEquals(usGovt, instance.USGovernmentFunding));
            Assert.IsTrue(Object.ReferenceEquals(international, instance.InternationalFunding));
            Assert.IsTrue(Object.ReferenceEquals(other, instance.Other));

            var json       = JsonConvert.SerializeObject(instance);
            var jsonObject = JsonConvert.DeserializeObject <OtherFunds>(json);

            Assert.AreEqual(binationalCommission, jsonObject.BinationalCommission);
            Assert.AreEqual(personal, jsonObject.Personal);
            Assert.AreEqual(evGovt, jsonObject.ExchangeVisitorGovernment);
            Assert.IsNotNull(jsonObject.InternationalFunding);
            Assert.IsNotNull(jsonObject.Other);
            Assert.IsNotNull(jsonObject.USGovernmentFunding);
            Assert.AreEqual(usGovt.Org1, jsonObject.USGovernmentFunding.Org1);
            Assert.AreEqual(usGovt.Amount1, jsonObject.USGovernmentFunding.Amount1);
            Assert.AreEqual(international.Org1, jsonObject.InternationalFunding.Org1);
            Assert.AreEqual(international.Amount1, jsonObject.InternationalFunding.Amount1);
        }
        public void TestFinancialInfo_MustHaveMinimumFunding()
        {
            var otherFunds                    = new OtherFunds(null, null, null, null, null, null);
            var programSponsorFunds           = "100";
            var receivedUsGovtFunds           = true;
            var printForm                     = true;
            Func <FinancialInfo> createEntity = () =>
            {
                var financialInfo = new FinancialInfo(
                    printForm: printForm,
                    receivedUSGovtFunds: receivedUsGovtFunds,
                    programSponsorFunds: programSponsorFunds,
                    otherFunds: otherFunds);
                return(financialInfo);
            };

            var validator = new FinancialInfoValidator();
            var instance  = createEntity();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            programSponsorFunds = "0";
            instance            = createEntity();
            result = validator.Validate(instance);
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(1, result.Errors.Count);
            Assert.AreEqual(FinancialInfoValidator.FUNDING_LESS_THAN_MINIMUM_AMOUNT_ERROR_MESSAGE, result.Errors.First().ErrorMessage);
            Assert.IsInstanceOfType(result.Errors.First().CustomState, typeof(FundingErrorPath));
        }
Ejemplo n.º 4
0
        public void TestGetSEVISEVBatchTypeExchangeVisitorFinancialInfo()
        {
            string binationalCommission = "commission";
            string personal             = "peronsal";
            string evGovt = "ev gov";
            Other  other  = new Other("name", "amount");
            USGovernmentFunding  usGovt        = new USGovernmentFunding(null, null, null, null, null, null);
            InternationalFunding international = new InternationalFunding(null, null, null, null, null, null);

            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: evGovt,
                binationalCommission: binationalCommission,
                personal: personal,
                usGovernmentFunding: usGovt,
                internationalFunding: international,
                other: other);

            var programSponsorFunds = "prog sponsor funds";
            var receivedUsGovtFunds = true;
            var printForm           = true;
            var financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            var instance = financialInfo.GetSEVISEVBatchTypeExchangeVisitorFinancialInfo();

            Assert.IsNotNull(instance.OtherFunds);
            Assert.AreEqual(financialInfo.PrintForm, instance.printForm);
            Assert.AreEqual(financialInfo.ProgramSponsorFunds, instance.ProgramSponsorFunds);
            Assert.AreEqual(financialInfo.ReceivedUSGovtFunds, instance.ReceivedUSGovtFunds);
            Assert.IsTrue(instance.ReceivedUSGovtFundsSpecified);
        }
Ejemplo n.º 5
0
        public void TestConstructor()
        {
            string binationalCommission = "commission";
            string personal             = "peronsal";
            string evGovt        = "ev gov";
            Other  other         = new Other("name", "amount");
            var    usGovt        = new USGovernmentFunding("us gov 1", null, "us gov value 1", null, null, null);
            var    international = new InternationalFunding("international org 1", null, "internation org 1 value", null, null, null);

            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: evGovt,
                binationalCommission: binationalCommission,
                personal: personal,
                usGovernmentFunding: usGovt,
                internationalFunding: international,
                other: other);

            var programSponsorFunds = "prog sponsor funds";
            var receivedUsGovtFunds = true;
            var printForm           = true;
            var instance            = new FinancialInfo(
                printForm,
                receivedUsGovtFunds,
                programSponsorFunds,
                otherFunds);

            Assert.IsTrue(Object.ReferenceEquals(otherFunds, instance.OtherFunds));
            Assert.AreEqual(programSponsorFunds, instance.ProgramSponsorFunds);
            Assert.AreEqual(receivedUsGovtFunds, instance.ReceivedUSGovtFunds);
            Assert.AreEqual(printForm, instance.PrintForm);
        }
Ejemplo n.º 6
0
        public void TestGetOtherFundsType()
        {
            string binationalCommission = "commission";
            string personal             = "peronsal";
            string evGovt = "ev gov";
            Other  other  = new Other("name", "amount");
            USGovernmentFunding  usGovt        = new USGovernmentFunding(null, null, null, null, null, null);
            InternationalFunding international = new InternationalFunding(null, null, null, null, null, null);

            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: evGovt,
                binationalCommission: binationalCommission,
                personal: personal,
                usGovernmentFunding: usGovt,
                internationalFunding: international,
                other: other);

            var instance = otherFunds.GetOtherFundsType();

            Assert.IsNotNull(instance);
            Assert.AreEqual(otherFunds.BinationalCommission, instance.BinationalCommission);
            Assert.AreEqual(otherFunds.ExchangeVisitorGovernment, instance.EVGovt);
            Assert.AreEqual(otherFunds.Personal, instance.Personal);

            Assert.IsNotNull(otherFunds.InternationalFunding);
            Assert.IsNotNull(otherFunds.Personal);
            Assert.IsNotNull(otherFunds.USGovernmentFunding);
        }
        public void TestOtherFunds_ShouldRunValidator()
        {
            OtherFunds           otherFunds          = null;
            var                  programSponsorFunds = "100";
            var                  receivedUsGovtFunds = true;
            var                  printForm           = true;
            Func <FinancialInfo> createEntity        = () =>
            {
                var financialInfo = new FinancialInfo(
                    printForm: printForm,
                    receivedUSGovtFunds: receivedUsGovtFunds,
                    programSponsorFunds: programSponsorFunds,
                    otherFunds: otherFunds);
                return(financialInfo);
            };
            var validator = new FinancialInfoValidator();
            var instance  = createEntity();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            otherFunds = new OtherFunds("a", null, null, null, null, null);
            instance   = createEntity();
            result     = validator.Validate(instance);
            Assert.IsFalse(result.IsValid);
        }
Ejemplo n.º 8
0
        public void TestConstructor_PrintFormIsFalse()
        {
            string binationalCommission = "commission";
            string personal             = "peronsal";
            string evGovt = "ev gov";
            Other  other  = new Other("name", "amount");
            USGovernmentFunding  usGovt        = new USGovernmentFunding(null, null, null, null, null, null);
            InternationalFunding international = new InternationalFunding(null, null, null, null, null, null);

            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: evGovt,
                binationalCommission: binationalCommission,
                personal: personal,
                usGovernmentFunding: usGovt,
                internationalFunding: international,
                other: other);

            var programSponsorFunds = "prog sponsor funds";
            var receivedUsGovtFunds = true;
            var printForm           = false;
            var instance            = new FinancialInfo(
                printForm,
                receivedUsGovtFunds,
                programSponsorFunds,
                otherFunds);

            Assert.AreEqual(receivedUsGovtFunds, instance.ReceivedUSGovtFunds);
            Assert.AreEqual(printForm, instance.PrintForm);
        }
Ejemplo n.º 9
0
        public void TestGetTotalFunding_HasOtherFunds()
        {
            OtherFunds otherFunds          = new OtherFunds("1.0", null, null, null, null, null);
            string     programSponsorFunds = null;
            var        receivedUsGovtFunds = true;
            var        printForm           = true;
            var        financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            Assert.AreEqual(1.0m, financialInfo.GetTotalFunding());
        }
Ejemplo n.º 10
0
        public void TestGetTotalFunding_HasEmtpyStringProgramSponsorFunds()
        {
            OtherFunds otherFunds          = null;
            string     programSponsorFunds = string.Empty;
            var        receivedUsGovtFunds = true;
            var        printForm           = true;
            var        financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            Assert.AreEqual(0.0m, financialInfo.GetTotalFunding());
        }
Ejemplo n.º 11
0
        public void TestGetEVPersonTypeFinancialInfo_NullOtherFunds()
        {
            OtherFunds otherFunds          = null;
            var        programSponsorFunds = "prog sponsor funds";
            var        receivedUsGovtFunds = true;
            var        printForm           = true;
            var        financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);
            var instance = financialInfo.GetEVPersonTypeFinancialInfo();

            Assert.IsNull(instance.OtherFunds);
        }
        /// <summary>
        /// Returns sevis participant financial information.
        /// </summary>
        /// <param name="participantExchangeVisitor">The exchange visitor.</param>
        /// <param name="orgFunding">The international organization funding.</param>
        /// <param name="usFunding">The US government funding for the participant.</param>
        /// <returns>The financial info object.</returns>
        public FinancialInfo GetFinancialInfo(ParticipantExchangeVisitor participantExchangeVisitor, ExchangeVisitorFundingDTO orgFunding, ExchangeVisitorFundingDTO usFunding)
        {
            Contract.Requires(participantExchangeVisitor != null, "The participant exchange visitor must not be null.");
            Func <decimal?, string> getFundingAsWholeDollarString = (value) =>
            {
                if (value.HasValue && value.Value > 0.0m)
                {
                    return(((int)value.Value).ToString());
                }
                else
                {
                    return(null);
                }
            };

            var receivedUsGovtFunds = false;

            if ((participantExchangeVisitor.FundingGovtAgency1.HasValue && participantExchangeVisitor.FundingGovtAgency1.Value > 0.0m) ||
                (participantExchangeVisitor.FundingGovtAgency2.HasValue && participantExchangeVisitor.FundingGovtAgency2.Value > 0.0m))
            {
                receivedUsGovtFunds = true;
            }
            var   programSponsorFunds = getFundingAsWholeDollarString(participantExchangeVisitor.FundingSponsor);
            Other other = null;

            if (participantExchangeVisitor.FundingOther.HasValue && participantExchangeVisitor.FundingOther.Value > 0.0m)
            {
                other = new Other(
                    name: participantExchangeVisitor.OtherName,
                    amount: getFundingAsWholeDollarString(participantExchangeVisitor.FundingOther));
            }

            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: getFundingAsWholeDollarString(participantExchangeVisitor.FundingVisGovt),
                binationalCommission: getFundingAsWholeDollarString(participantExchangeVisitor.FundingVisBNC),
                personal: getFundingAsWholeDollarString(participantExchangeVisitor.FundingPersonal),
                usGovernmentFunding: usFunding != null && !usFunding.IsEmpty() ? usFunding.GetUSGovt() : null,
                internationalFunding: orgFunding != null && !orgFunding.IsEmpty() ? orgFunding.GetInternational() : null,
                other: other);

            var financialInfo = new FinancialInfo(
                printForm: true,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            return(financialInfo);
        }
Ejemplo n.º 13
0
        public void TestGetSEVISEVBatchTypeExchangeVisitorFinancialInfo_OtherFundsIsNull()
        {
            OtherFunds otherFunds          = null;
            var        programSponsorFunds = "prog sponsor funds";
            var        receivedUsGovtFunds = true;
            var        printForm           = true;
            var        financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            var instance = financialInfo.GetSEVISEVBatchTypeExchangeVisitorFinancialInfo();

            Assert.IsNull(instance.OtherFunds);
        }
Ejemplo n.º 14
0
        public void TestGetChangeDetail_SameInstance()
        {
            OtherFunds otherFunds          = new OtherFunds("1.0", null, null, null, null, null);
            string     programSponsorFunds = null;
            var        receivedUsGovtFunds = true;
            var        printForm           = true;
            var        financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            var changeDetail = financialInfo.GetChangeDetail(financialInfo);

            Assert.IsFalse(changeDetail.HasChanges());
        }
Ejemplo n.º 15
0
        public void TestGetTotalFunding_AllFundingValuesNull()
        {
            string binationalCommission = null;
            string personal             = null;
            string evGovt = null;
            Other  other  = null;
            USGovernmentFunding  usGovt        = null;
            InternationalFunding international = null;
            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: evGovt,
                binationalCommission: binationalCommission,
                personal: personal,
                usGovernmentFunding: usGovt,
                internationalFunding: international,
                other: other);

            Assert.AreEqual(0.0m, otherFunds.GetTotalFunding());
        }
Ejemplo n.º 16
0
        public void TestGetTotalFunding_HasUSGovernmentFunding()
        {
            string binationalCommission = null;
            string personal             = String.Empty;
            string evGovt = null;
            Other  other  = null;
            USGovernmentFunding  usGovt        = new USGovernmentFunding(null, null, "1.0", null, null, null);
            InternationalFunding international = null;
            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: evGovt,
                binationalCommission: binationalCommission,
                personal: personal,
                usGovernmentFunding: usGovt,
                internationalFunding: international,
                other: other);

            Assert.AreEqual(1.0m, otherFunds.GetTotalFunding());
        }
Ejemplo n.º 17
0
        public void TestGetTotalFunding_HasWhitespacePersonalFunding()
        {
            string binationalCommission = null;
            string personal             = " ";
            string evGovt = null;
            Other  other  = new Other("name", "amount");
            USGovernmentFunding  usGovt        = null;
            InternationalFunding international = new InternationalFunding(null, null, null, null, null, null);
            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: evGovt,
                binationalCommission: binationalCommission,
                personal: personal,
                usGovernmentFunding: usGovt,
                internationalFunding: international,
                other: other);

            Assert.AreEqual(0.0m, otherFunds.GetTotalFunding());
        }
Ejemplo n.º 18
0
        public void TestGetOtherFundsNullableType_NullOther()
        {
            string binationalCommission = "commission";
            string personal             = "peronsal";
            string evGovt = "ev gov";
            Other  other  = null;
            USGovernmentFunding  usGovt        = new USGovernmentFunding(null, null, null, null, null, null);
            InternationalFunding international = new InternationalFunding(null, null, null, null, null, null);

            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: evGovt,
                binationalCommission: binationalCommission,
                personal: personal,
                usGovernmentFunding: usGovt,
                internationalFunding: international,
                other: other);
            var instance = otherFunds.GetOtherFundsNullableType();

            Assert.IsNotNull(instance);
            Assert.IsNull(otherFunds.Other);
        }
Ejemplo n.º 19
0
        public void TestJsonSerialization()
        {
            string binationalCommission = "commission";
            string personal             = "peronsal";
            string evGovt        = "ev gov";
            Other  other         = new Other("name", "amount");
            var    usGovt        = new USGovernmentFunding("us gov 1", null, "us gov value 1", null, null, null);
            var    international = new InternationalFunding("international org 1", null, "internation org 1 value", null, null, null);

            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: evGovt,
                binationalCommission: binationalCommission,
                personal: personal,
                usGovernmentFunding: usGovt,
                internationalFunding: international,
                other: other);

            var programSponsorFunds = "prog sponsor funds";
            var receivedUsGovtFunds = true;
            var printForm           = true;
            var instance            = new FinancialInfo(
                printForm,
                receivedUsGovtFunds,
                programSponsorFunds,
                otherFunds);
            var json       = JsonConvert.SerializeObject(instance);
            var jsonObject = JsonConvert.DeserializeObject <FinancialInfo>(json);

            Assert.AreEqual(receivedUsGovtFunds, jsonObject.ReceivedUSGovtFunds);
            Assert.AreEqual(printForm, jsonObject.PrintForm);
            Assert.IsNotNull(jsonObject.OtherFunds);
            Assert.IsNotNull(jsonObject.OtherFunds.InternationalFunding);
            Assert.IsNotNull(jsonObject.OtherFunds.USGovernmentFunding);

            //spot checks
            Assert.AreEqual(usGovt.Org1, jsonObject.OtherFunds.USGovernmentFunding.Org1);
            Assert.AreEqual(international.Org1, jsonObject.OtherFunds.InternationalFunding.Org1);
        }
Ejemplo n.º 20
0
        public void TestGetChangeDetail_HasChangeInChild()
        {
            OtherFunds otherFunds          = new OtherFunds("1.0", null, null, null, null, null);
            string     programSponsorFunds = null;
            var        receivedUsGovtFunds = true;
            var        printForm           = true;
            var        financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            OtherFunds someOtherFunds     = new OtherFunds("2.0", null, null, null, null, null);
            var        otherFinancialInfo = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: someOtherFunds);

            var changeDetail = financialInfo.GetChangeDetail(otherFinancialInfo);

            Assert.IsTrue(changeDetail.HasChanges());
        }