예제 #1
0
        public void TryRemove_WhenTableConfiguredAndEntryNotPresent_ReturnsFalse()
        {
            var database = Fake.Database(true);

            var result = database.TryRemove <int, Person>(1);

            Assert.IsFalse(result);
        }
예제 #2
0
        public void TryAddOrUpdate_WhenTableConfigured_ReturnsTrue()
        {
            var database = Fake.Database(true);

            var result = database.TryAddOrUpdate(1, new Person());

            Assert.IsTrue(result);
        }
예제 #3
0
        public void TryRemoveTable_WhenTableConfigured_ReducesTableCachedCountByOne()
        {
            var database = Fake.Database(true, true);

            database.TryRemoveTable <Person>();

            Assert.AreEqual(1, database.TotalTablesCount);
        }
예제 #4
0
        public void SubmittingEntry_ToTheCache_IncreasesCacheCountByOne()
        {
            var database = Fake.Database(true);
            var people   = new PersonRepository();
            var person   = people.GetSingle(1);

            database.TryAddOrUpdate(1, person);

            Assert.AreEqual(1, database.TableItemsCachedCount <Person>());
            Assert.AreEqual(0, database.TableItemsCachedCount <Role>());
        }
예제 #5
0
        public void SubmittingCrossTypeEntries_ToTheCache_IncreasesCacheCountByTwo()
        {
            var database = Fake.Database();
            var people   = new PersonRepository();
            var roles    = new RoleRepository();
            var person   = people.GetSingle(1);
            var role     = roles.GetSingle(1);

            database.AddOrUpdate(1, person, people.GetSingle);
            database.AddOrUpdate(1, role, roles.GetSingle);

            Assert.AreEqual(1, database.TableItemsCachedCount <Person>());
            Assert.AreEqual(1, database.TableItemsCachedCount <Role>());
        }
예제 #6
0
        public void Clear_WhenRecordsCached_ClearsAll()
        {
            var database = Fake.Database(true, true);

            database.TryGet <int, Person>(1, out _);
            database.TryGet <int, Person>(2, out _);
            database.TryGet <int, Role>(1, out _);
            database.TryGet <int, Role>(2, out _);

            database.Clear();

            Assert.AreEqual(0, database.TableItemsCachedCount <Person>());
            Assert.AreEqual(0, database.TableItemsCachedCount <Role>());
            Assert.AreEqual(0, database.TotalTablesCount);
        }
예제 #7
0
        public void EagerAddingTwoTables_WhenThereAreNoTables_SetsTableCountToTwo()
        {
            var database = Fake.Database(true, true);

            Assert.AreEqual(2, database.TotalTablesCount);
        }