public Rate Add(Rate item) { var newRate = (Rate)item.Clone(); newRate.Id = !_rates.Any() ? 1 : _rates.Max(rate => rate.Id) + 1; _rates.Add(newRate); return (Rate)newRate.Clone(); }
public Rate Update(Rate item) { var existRate = _rates.SingleOrDefault(rate => rate.Id == item.Id); if (existRate == null) { throw new NullReferenceException(); } existRate.RateInformation = item.RateInformation; return (Rate)existRate.Clone(); }
public void AddTest() { var name = Guid.NewGuid().ToString(); var newRate = new Rate { RateInformation = name }; var AddedRate = service.Add(newRate); Assert.IsNotNull(AddedRate); Assert.IsTrue(AddedRate.Id > 0); Assert.AreEqual(AddedRate.RateInformation, name); }