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); }
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)); }
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)); }