/// <summary> /// Checks that when a region is created twice, the CreateRegion method returns false. /// </summary> public void CreateDuplicateRegion() { LightHouse.Core.Caching.DataCache dataCache = new LightHouse.Core.Caching.DataCache(); String dataRegionName = "Family"; Assert.True(dataCache.CreateRegion(dataRegionName)); Assert.False(dataCache.CreateRegion(dataRegionName)); }
/// <summary> /// Checks that an object is removed from a specific region. /// </summary> public void RemoveObjectFromSpecificRegion() { LightHouse.Core.Caching.DataCache dataCache = new LightHouse.Core.Caching.DataCache(); String id = Guid.NewGuid().ToString(); Person person = new Person() { ID = id, Reference = "1671", FirstName = new Localization.LocalString("Homer"), LastName = new Localization.LocalString("Simpson"), }; String dataRegionName = "Family"; Assert.True(dataCache.CreateRegion(dataRegionName)); dataCache.Add(person.ID, person, dataRegionName); Person cachedPerson = dataCache.Get<Person>(person.ID, dataRegionName); Assert.NotNull(cachedPerson); dataCache.Remove(person.ID, dataRegionName); Person removedPerson = dataCache.Get<Person>(person.ID, dataRegionName); Assert.Null(removedPerson); }
/// <summary> /// Checks if a region can be created and then clears anything in the region. /// </summary> public void CreateAndClearRegion() { LightHouse.Core.Caching.DataCache dataCache = new LightHouse.Core.Caching.DataCache(); String id = Guid.NewGuid().ToString(); Person person = new Person() { ID = id, Reference = "1671", FirstName = new Localization.LocalString("Homer"), LastName = new Localization.LocalString("Simpson"), }; String dataRegionName = "Family"; Assert.True(dataCache.CreateRegion(dataRegionName)); dataCache.Add(person.ID, person, dataRegionName); LightHouse.Core.Caching.DataRegion dataRegion = dataCache.Regions[dataRegionName]; Assert.True((dataRegion.Objects.Count == 1), "Item was not added to region"); dataCache.ClearRegion(dataRegionName); Assert.True((dataRegion.Objects.Count == 0), "Region was not cleared"); }