public void CrudTest() { _repository.TryAdd(new Opm(_validCode)); Opm opm; Assert.IsTrue(_repository.TryGetOpm(_validCode, out opm)); Assert.AreEqual(_validCode, opm.Code); _repository.TryRemoveOpm(opm.Code); Assert.IsFalse(_repository.TryGetOpm(_validCode, out opm)); }
public static void Fill(IOpmRepository repo) { using (StreamReader sr = new StreamReader(HttpContext.Current.Server.MapPath("Persistence/OpmRepoSampleData.csv"))) { string currentLine; while ((currentLine = sr.ReadLine()) != null) { repo.TryAdd(new Opm(new EanEicCode(currentLine))); } } }
public static void Fill(IOpmRepository repo, string path) { using (StreamReader sr = new StreamReader(path)) { string currentLine; while ((currentLine = sr.ReadLine()) != null) { if (!repo.TryAdd(new Opm(new EanEicCode(currentLine)))) { throw new Exception("Failed to add OPM [code= " + currentLine + "] to repository."); } } } }