Beispiel #1
0
        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);
        }
Beispiel #2
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 #3
0
        public void AddTable_WithNullGet_ThrowsArgumentNull()
        {
            var database = new LazyDatabase();

            Assert.Throws <ArgumentNullException>(() => database.TryAddTable <int, object>(null));
        }
Beispiel #4
0
        public void AddingTable_WithNullLoader_ThrowsArgumentNullException()
        {
            var database = new LazyDatabase();

            Assert.Throws <ArgumentNullException>(() => database.TryAddTable <int, Person>(null));
        }