public void TestGetAmountAsWholeDollarString_IsWholeValue()
        {
            decimal?x     = 1m;
            var     model = new ExchangeVisitorFundingDTO();

            Assert.AreEqual("1", model.GetAmountAsWholeDollarString(x));
        }
        public void TestIsEmpty_AllValuesWhitespace()
        {
            var dto = new ExchangeVisitorFundingDTO
            {
                Amount1    = null,
                Amount2    = null,
                Org1       = " ",
                Org2       = " ",
                OtherName1 = " ",
                OtherName2 = " "
            };

            Assert.IsTrue(dto.IsEmpty());
        }
        public void TestIsEmpty_AllValuesEmpty()
        {
            var dto = new ExchangeVisitorFundingDTO
            {
                Amount1    = null,
                Amount2    = null,
                Org1       = String.Empty,
                Org2       = String.Empty,
                OtherName1 = String.Empty,
                OtherName2 = String.Empty
            };

            Assert.IsTrue(dto.IsEmpty());
        }
        public void TestIsEmpty_Other2HasValue()
        {
            var dto = new ExchangeVisitorFundingDTO
            {
                Amount1    = null,
                Amount2    = null,
                Org1       = null,
                Org2       = null,
                OtherName1 = null,
                OtherName2 = "1"
            };

            Assert.IsFalse(dto.IsEmpty());
        }
        public void TestIsEmpty_Amount2HasZeroValue()
        {
            var dto = new ExchangeVisitorFundingDTO
            {
                Amount1    = null,
                Amount2    = 0m,
                Org1       = null,
                Org2       = null,
                OtherName1 = null,
                OtherName2 = null
            };

            Assert.IsTrue(dto.IsEmpty());
        }
        public void TestGetInternational()
        {
            var dto = new ExchangeVisitorFundingDTO
            {
                Amount1    = 1.1m,
                Amount2    = 2.2m,
                Org1       = "org 1",
                Org2       = "org 2",
                OtherName1 = "other 1",
                OtherName2 = "other 2"
            };
            var instance = dto.GetInternational();

            Assert.AreEqual("1", instance.Amount1);
            Assert.AreEqual("2", instance.Amount2);
            Assert.AreEqual(dto.Org1, instance.Org1);
            Assert.AreEqual(dto.Org2, instance.Org2);
            Assert.AreEqual(dto.OtherName1, instance.OtherName1);
            Assert.AreEqual(dto.OtherName2, instance.OtherName2);
        }
        public void TestGetAmountAsWholeDollarString_Null()
        {
            var model = new ExchangeVisitorFundingDTO();

            Assert.IsNull(model.GetAmountAsWholeDollarString(null));
        }
        /// <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);
        }