public void LazyAddingTable_WhenThereAreNoTables_SetsTableCountToOne() { var database = new LazyDatabase(); var people = new PersonRepository(); database.Get(1, people.GetSingle); Assert.AreEqual(1, database.TotalTablesCount); }
public void GetFromDatabase_WhenLifetimeHasNotExpired_DoesNotReload() { var database = new LazyDatabase(TimeSpan.FromHours(100)); var people = new PersonRepository(); database.Get(1, people.GetSingle); database.TryGet(1, out Person p); database.TryGet(1, out p); Assert.AreEqual(1, people.TimesLoaded); }
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 Get_WithNullGet_ThrowsArgumentNull() { var database = new LazyDatabase(); Assert.Throws <ArgumentNullException>(() => database.Get <int, object>(1, null)); }