public void mustWriteDocumentIfDoesntExists() { var fileManager = new FileDataManager(); var model = new NetWorth { RecordId = "bingo", Entries = new List <FinancialRecord> { new FinancialRecord { Id = 3, Currency = "CDN", RecordType = RecordType.ShortTermAsset, Name = "Chequing", Rate = 10.5, Value = 1000 }, new FinancialRecord { Id = 4, Currency = "CDN", RecordType = RecordType.ShortTermLiability, Name = "Mortgage", Rate = 10.5, Value = 1000 } } }; fileManager.CreateOrUpdate(model); var foundModel = fileManager.Read(model.RecordId); Assert.IsNotNull(foundModel); }
public void mustUpdateDocumentIftExists() { var fileManager = new FileDataManager(); var model = new NetWorth { RecordId = "bingo", Entries = new List <FinancialRecord> { new FinancialRecord { Id = 3, Currency = "CDN", RecordType = RecordType.ShortTermAsset, Name = "Chequing", Rate = 10.5, Value = 1000 }, new FinancialRecord { Id = 4, Currency = "CDN", RecordType = RecordType.ShortTermLiability, Name = "Mortgage", Rate = 10.5, Value = 1000 } } }; fileManager.CreateOrUpdate(model); var model2 = new NetWorth { RecordId = "bingo", Entries = new List <FinancialRecord> { new FinancialRecord { Id = model.Entries[0].Id, Currency = "CDN", RecordType = RecordType.ShortTermAsset, Name = "Chequing", Rate = 999, Value = 1000 }, new FinancialRecord { Id = model.Entries[1].Id, Currency = "CDN", RecordType = RecordType.ShortTermLiability, Name = "Mortgage", Rate = 999, Value = 1000 } } }; fileManager.CreateOrUpdate(model2); var found = fileManager.Read("bingo"); Assert.IsNotNull(found); Assert.AreEqual(model2.Entries[0].Rate, found.Entries[0].Rate); }