/// <summary> /// Checks that an object is removed from a default region. /// </summary> public void RemoveObjectFromDefaultRegion() { 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"), }; dataCache.Add(person.ID, person); Assert.True(dataCache.Regions.ContainsKey("default"), "default region was not created"); LightHouse.Core.Caching.DataRegion defaultDataRegion = dataCache.Regions["default"]; Person cachedPerson = dataCache.Get<Person>(person.ID); Assert.NotNull(cachedPerson); dataCache.Remove(person.ID); Person removedPerson = dataCache.Get<Person>(person.ID); Assert.Null(removedPerson); }
/// <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> /// REVIEW: Checks that an object from a region is removed. If the region does not exist, it is created. /// </summary> public void CreateRegionIfDoesNotExist() { LightHouse.Core.Caching.DataCache dataCache = new LightHouse.Core.Caching.DataCache(); dataCache.Remove("key","region"); Assert.True(dataCache.ContainsRegion("region")); }