using System; using System.Linq; using LCU.API.Internal.Operations.IncentiveApi.Models.GoalDispersal; using LCU.Library.Internal.IncentiveApiModels.Enums; using NUnit.Framework; namespace Application.UnitTests.Models { public class GoalDispersalReceiptTest { [Test] public void GoalDispersalReceiptItem_Does_Not_Require_Name() { var GDR = new GoalDispersalReceipt(10, GoalDispersalStrategy.ExtrapolateFromExistingGoals); GDR.AddNewDispersalError(GoalDispersalError.ErrorsDuringDisperse, "1", "ERROR"); GDR.AddNewDispersalError(GoalDispersalError.ErrorsDuringDisperse, "2", "ERROR", null); var obj = new {name = "batman"}; var testFunc = new Func((string name) => { if (name == "batman") return null; return "name"; }); GDR.AddNewDispersalError(GoalDispersalError.ErrorsDuringDisperse, "3", "ERROR", obj.name); GDR.AddNewDispersalError(GoalDispersalError.ErrorsDuringDisperse, "4", "ERROR", testFunc(obj.name)); Assert.AreEqual(4,GDR.GoalDispersalErrors.Count); Assert.AreEqual(3, GDR.GoalDispersalErrors.Count(x => x.EmployeeName == null)); } } }