public static LazyDatabase Database(bool includePeople = false, bool includeRoles = false) { var database = new LazyDatabase(); if (includePeople) { var people = new PersonRepository(); database.TryAddTable <int, Person>(people.GetSingle); } if (includeRoles) { var roles = new RoleRepository(); database.TryAddTable <int, Role>(roles.GetSingle); } return(database); }
public void GetFromDatabase_WhenLifetimeIsOverridenAndHasExpired_Reloads() { var database = new LazyDatabase(); var people = new PersonRepository(); database.TryAddTable <int, Person>(people.GetSingle, TimeSpan.Zero); database.TryGet(1, out Person p); database.TryGet(1, out p); database.Get(1, people.GetSingle); Assert.AreEqual(3, people.TimesLoaded); }
public void AddTable_WithNullGet_ThrowsArgumentNull() { var database = new LazyDatabase(); Assert.Throws <ArgumentNullException>(() => database.TryAddTable <int, object>(null)); }
public void AddingTable_WithNullLoader_ThrowsArgumentNullException() { var database = new LazyDatabase(); Assert.Throws <ArgumentNullException>(() => database.TryAddTable <int, Person>(null)); }