public void GetByIdTest() { NpvProfile npvP = null; using (var context = this.TestingContext) { var repository = new NpvProfileRepository(context); npvP = repository.GetById(1); } Assert.IsNotNull(npvP, "npvP is null"); Assert.IsTrue(npvP.Id == 1, "npvP.Id is not 1"); Assert.IsNotNull(npvP.CashFlows, "CashFlow is null"); Assert.IsTrue(npvP.CashFlows.Count == 3, "CashFlow count is not 3"); Assert.IsNotNull(npvP.NPVs, "NPVs is null"); Assert.IsTrue(npvP.NPVs.Count == 3, "CashFlow count is not 3"); }
public void GetAllTest() { List <NpvProfile> list = null; using (var context = this.TestingContext) { var repository = new NpvProfileRepository(context); list = repository.GetAll() as List <NpvProfile>; } Assert.IsNotNull(list, "list is null"); Assert.IsTrue(list.Count == 2, "list.Count is not 2"); Assert.IsNotNull(list[0].CashFlows, "CashFlow is null"); Assert.IsTrue(list[0].CashFlows.Count == 3, "CashFlow count is not 3"); Assert.IsNotNull(list[0].NPVs, "NPVs is null"); Assert.IsTrue(list[0].NPVs.Count == 3, "CashFlow count is not 3"); }
public void UpdateTest() { NpvProfile npvP = null; using (var context = this.TestingContext) { var repository = new NpvProfileRepository(context); npvP = new NpvProfile { Id = 2, Name = "Profile 2 Updated", InitialCost = 100M, LowerBoundRate = 0.1F, UpperBoundRate = 0.2F, RateIncrement = 0.5F, CashFlows = new List <CashFlow> { new CashFlow { Value = 1 } }, NPVs = new List <RateNpv> { new RateNpv { Rate = 0.1F, Npv = 1000M } } }; npvP = repository.Update(npvP); } Assert.IsNotNull(npvP, "npvP is null"); Assert.AreEqual(2, npvP.Id, "Id is not equal"); Assert.AreEqual("Profile 2 Updated", npvP.Name, "Name is not equal"); Assert.IsNotNull(npvP.CashFlows, "CashFlow is null"); Assert.IsTrue(npvP.CashFlows.Count == 1, "CashFlow count is not 1"); Assert.IsNotNull(npvP.NPVs, "NPVs is null"); Assert.IsTrue(npvP.NPVs.Count == 1, "CashFlow count is not 1"); }