Beispiel #1
0
        public void LazyAddingTable_WhenThereAreNoTables_SetsTableCountToOne()
        {
            var database = new LazyDatabase();
            var people   = new PersonRepository();

            database.Get(1, people.GetSingle);

            Assert.AreEqual(1, database.TotalTablesCount);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public void Get_WithNullGet_ThrowsArgumentNull()
        {
            var database = new LazyDatabase();

            Assert.Throws <ArgumentNullException>(() => database.Get <int, object>(1, null));
        }