示例#1
0
        public void TestInternational_ShouldRunValidator()
        {
            string binationalCommission = "1";
            string personal             = "2";
            string evGovt = "3";
            Other  other  = new Other("name", "1");
            USGovernmentFunding  usGovt        = new USGovernmentFunding("us 1", null, "1", null, null, null);
            InternationalFunding international = null;
            Func <OtherFunds>    createEntity  = () =>
            {
                return(new OtherFunds(exchangeVisitorGovernment: evGovt, binationalCommission: binationalCommission, personal: personal, usGovernmentFunding: usGovt, internationalFunding: international, other: other));
            };
            var validator = new OtherFundsValidator();
            var instance  = createEntity();

            Assert.IsNull(instance.InternationalFunding);
            var result = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            international = new InternationalFunding(null, null, null, null, null, null);
            instance      = createEntity();
            result        = validator.Validate(instance);
            Assert.IsFalse(result.IsValid);
        }
示例#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);
        }
示例#3
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);
        }
示例#4
0
        public void TestEVGovt_ExceedsMaxLength()
        {
            string binationalCommission = "1";
            string personal             = "2";
            string evGovt = "3";
            Other  other  = new Other("name", "1");
            USGovernmentFunding  usGovt        = new USGovernmentFunding("us 1", null, "1", null, null, null);
            InternationalFunding international = new InternationalFunding("int 1", null, "2", null, null, null);
            Func <OtherFunds>    createEntity  = () =>
            {
                return(new OtherFunds(exchangeVisitorGovernment: evGovt, binationalCommission: binationalCommission, personal: personal, usGovernmentFunding: usGovt, internationalFunding: international, other: other));
            };
            var validator = new OtherFundsValidator();
            var instance  = createEntity();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            evGovt   = new string('1', OtherFundsValidator.AMOUNT_MAX_LENGTH + 1);
            instance = createEntity();
            result   = validator.Validate(instance);
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(1, result.Errors.Count);
            Assert.AreEqual(OtherFundsValidator.EXCHANGE_VISITOR_GOVERNMENT_FUNDING_ERROR_MESSAGE, result.Errors.First().ErrorMessage);
            Assert.IsInstanceOfType(result.Errors.First().CustomState, typeof(FundingErrorPath));
        }
示例#5
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);
        }
示例#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);
        }
示例#7
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);
        }
示例#8
0
        public void TestPersonal_DoesNotContainDigits()
        {
            string binationalCommission = "1";
            string personal             = "2";
            string evGovt = "3";
            Other  other  = new Other("name", "1");
            USGovernmentFunding  usGovt        = new USGovernmentFunding("us 1", null, "1", null, null, null);
            InternationalFunding international = new InternationalFunding("int 1", null, "2", null, null, null);
            Func <OtherFunds>    createEntity  = () =>
            {
                return(new OtherFunds(exchangeVisitorGovernment: evGovt, binationalCommission: binationalCommission, personal: personal, usGovernmentFunding: usGovt, internationalFunding: international, other: other));
            };
            var validator = new OtherFundsValidator();
            var instance  = createEntity();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            personal = "a";
            instance = createEntity();
            result   = validator.Validate(instance);
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(1, result.Errors.Count);
            Assert.AreEqual(OtherFundsValidator.PERSONAL_ERROR_MESSAGE, result.Errors.First().ErrorMessage);
            Assert.IsInstanceOfType(result.Errors.First().CustomState, typeof(FundingErrorPath));
        }
示例#9
0
        public void TestGetTotalFunding_HasWhitespaceAmount2Funding()
        {
            var agencyCode1   = InternationalOrgCodeType.ECOSOC;
            var agencyCode2   = InternationalOrgCodeType.EEC;
            var international = new InternationalFunding(
                org1: agencyCode1.ToString(),
                amount1: null,
                otherName1: "other 1 name",
                org2: agencyCode2.ToString(),
                amount2: "amount 2",
                otherName2: " "
                );

            Assert.AreEqual(0.0m, international.GetTotalFunding());
        }
示例#10
0
        public void TestConstructor()
        {
            var org1          = "org1";
            var org2          = "org2";
            var amount1       = "amount 1";
            var amount2       = "amount 2";
            var otherName1    = "other 1";
            var otherName2    = "other 2";
            var international = new InternationalFunding(org1, otherName1, amount1, org2, otherName2, amount2);

            Assert.AreEqual(org1, international.Org1);
            Assert.AreEqual(org2, international.Org2);
            Assert.AreEqual(amount1, international.Amount1);
            Assert.AreEqual(amount2, international.Amount2);
            Assert.AreEqual(otherName1, international.OtherName1);
            Assert.AreEqual(otherName2, international.OtherName2);
        }
示例#11
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());
        }
示例#12
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());
        }
示例#13
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());
        }
示例#14
0
        public void TestJsonSerialization()
        {
            var org1          = "org1";
            var org2          = "org2";
            var amount1       = "amount 1";
            var amount2       = "amount 2";
            var otherName1    = "other 1";
            var otherName2    = "other 2";
            var international = new InternationalFunding(org1, otherName1, amount1, org2, otherName2, amount2);

            var json           = JsonConvert.SerializeObject(international);
            var jsonTestObject = JsonConvert.DeserializeObject <InternationalFunding>(json);

            Assert.AreEqual(org1, jsonTestObject.Org1);
            Assert.AreEqual(org2, jsonTestObject.Org2);
            Assert.AreEqual(amount1, jsonTestObject.Amount1);
            Assert.AreEqual(amount2, jsonTestObject.Amount2);
            Assert.AreEqual(otherName1, jsonTestObject.OtherName1);
            Assert.AreEqual(otherName2, jsonTestObject.OtherName2);
        }
示例#15
0
        public void TestGetOtherFundsTypeInternational_OtherInternationalOrgAgency1()
        {
            var agencyCode1   = InternationalOrgCodeType.OTHER;
            var international = new InternationalFunding(
                org1: agencyCode1.ToString(),
                amount1: "amount 1",
                otherName1: "other 1 name",
                org2: null,
                amount2: null,
                otherName2: null
                );
            var instance = international.GetOtherFundsTypeInternational();

            Assert.AreEqual(international.Amount1, instance.Amount1);
            Assert.AreEqual(agencyCode1, instance.Org1);
            Assert.AreEqual(international.OtherName1, instance.OtherName1);

            Assert.IsNull(instance.OtherName2);
            Assert.IsFalse(instance.Org2Specified);
        }
示例#16
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);
        }
示例#17
0
        public void TestGetOtherFundsNullableTypeUSGovt()
        {
            var agencyCode1   = InternationalOrgCodeType.ECOSOC;
            var agencyCode2   = InternationalOrgCodeType.EEC;
            var international = new InternationalFunding(
                org1: agencyCode1.ToString(),
                amount1: "amount 1",
                otherName1: "other 1 name",
                org2: agencyCode2.ToString(),
                amount2: "amount 2",
                otherName2: "other 2 name"
                );

            var instance = international.GetOtherFundsNullableTypeInternational();

            Assert.AreEqual(international.Amount1, instance.Amount1);
            Assert.AreEqual(international.Org1, instance.Org1);
            Assert.AreEqual(international.OtherName1, instance.OtherName1);
            Assert.AreEqual(international.Amount2, instance.Amount2);
            Assert.AreEqual(international.Org2, instance.Org2);
            Assert.AreEqual(international.OtherName2, instance.OtherName2);
        }
示例#18
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);
        }
示例#19
0
        public void TestGetOtherFundsTypeInternational_InternationalOrg1And2()
        {
            var agencyCode1   = InternationalOrgCodeType.EEC;
            var agencyCode2   = InternationalOrgCodeType.ESCAP;
            var international = new InternationalFunding(
                org1: agencyCode1.ToString(),
                amount1: "amount 1",
                otherName1: null,
                org2: agencyCode2.ToString(),
                amount2: "amount 2",
                otherName2: null
                );
            var instance = international.GetOtherFundsTypeInternational();

            Assert.AreEqual(international.Amount1, instance.Amount1);
            Assert.AreEqual(agencyCode1, instance.Org1);

            Assert.AreEqual(international.Amount2, instance.Amount2);
            Assert.AreEqual(agencyCode2, instance.Org2);

            Assert.IsNull(instance.OtherName1);
            Assert.IsNull(instance.OtherName2);
            Assert.IsTrue(instance.Org2Specified);
        }