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 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); }
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); }
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)); }
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 instance = new USGovernmentFunding(org1, otherName1, amount1, org2, otherName2, amount2); Assert.AreEqual(org1, instance.Org1); Assert.AreEqual(org2, instance.Org2); Assert.AreEqual(amount1, instance.Amount1); Assert.AreEqual(amount2, instance.Amount2); Assert.AreEqual(otherName1, instance.OtherName1); Assert.AreEqual(otherName2, instance.OtherName2); var json = JsonConvert.SerializeObject(instance); var jsonTestObject = JsonConvert.DeserializeObject <USGovernmentFunding>(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); }
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)); }
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); }
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); }
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 TestGetTotalFunding_HasWhitespaceAmount2Funding() { var agencyCode1 = GovAgencyCodeType.OTHER; var agencyCode2 = GovAgencyCodeType.OTHER; var usGov = new USGovernmentFunding( org1: agencyCode1.ToString(), amount1: null, otherName1: "other 1 name", org2: agencyCode2.ToString(), amount2: "amount 2", otherName2: " " ); Assert.AreEqual(0.0m, usGov.GetTotalFunding()); }
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()); }
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()); }
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()); }
public void TestGetOtherFundsTypeUSGovt_USGovAgency1Only() { var agencyCode1 = GovAgencyCodeType.DOE; var usGov = new USGovernmentFunding( org1: agencyCode1.ToString(), amount1: "amount 1", otherName1: null, org2: null, amount2: null, otherName2: null ); var instance = usGov.GetOtherFundsTypeUSGovt(); Assert.AreEqual(usGov.Amount1, instance.Amount1); Assert.AreEqual(agencyCode1, instance.Org1); Assert.IsNull(instance.OtherName1); Assert.IsNull(instance.OtherName2); Assert.IsFalse(instance.Org2Specified); }
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); }
public void TestGetOtherFundsNullableTypeUSGovt() { var agencyCode1 = GovAgencyCodeType.BBG; var agencyCode2 = GovAgencyCodeType.DOED; var usGov = new USGovernmentFunding( org1: agencyCode1.ToString(), amount1: "amount 1", otherName1: "other 1 name", org2: agencyCode2.ToString(), amount2: "amount 2", otherName2: "other 2 name" ); var instance = usGov.GetOtherFundsNullableTypeUSGovt(); Assert.AreEqual(usGov.Amount1, instance.Amount1); Assert.AreEqual(usGov.Org1, instance.Org1); Assert.AreEqual(usGov.OtherName1, instance.OtherName1); Assert.AreEqual(usGov.Amount2, instance.Amount2); Assert.AreEqual(usGov.Org2, instance.Org2); Assert.AreEqual(usGov.OtherName2, instance.OtherName2); }
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); }
public void TestGetOtherFundsTypeUSGovt_OtherUsGovAgency1And2() { var agencyCode1 = GovAgencyCodeType.OTHER; var agencyCode2 = GovAgencyCodeType.OTHER; var usGov = new USGovernmentFunding( org1: agencyCode1.ToString(), amount1: "amount 1", otherName1: "other 1 name", org2: agencyCode2.ToString(), amount2: "amount 2", otherName2: "other 2 name" ); var instance = usGov.GetOtherFundsTypeUSGovt(); Assert.AreEqual(usGov.Amount1, instance.Amount1); Assert.AreEqual(agencyCode1, instance.Org1); Assert.AreEqual(usGov.OtherName1, instance.OtherName1); Assert.AreEqual(usGov.Amount2, instance.Amount2); Assert.AreEqual(agencyCode2, instance.Org2); Assert.AreEqual(usGov.OtherName2, instance.OtherName2); Assert.IsTrue(instance.Org2Specified); }