public void AddToDictionary_OverwritesWhatsAlreadyCached() { CodeTableCache cache = new CodeTableCache(); List <CaseStatusType> csList = new List <CaseStatusType>(); csList.Add(new CaseStatusType() { Code = "C", Description = "Desc" }); Assert.IsFalse(cache.CodeTableDictionary.ContainsKey(typeof(CaseStatusType)), "CaseStatusType was not null to start with"); cache.AddToDictionary(csList); Assert.AreSame(csList, cache.CodeTableDictionary[typeof(CaseStatusType)], "List was not added to the dictionary"); List <CaseStatusType> newList = new List <CaseStatusType>(); newList.Add(new CaseStatusType() { Code = "C", Description = "Desc" }); newList.Add(new CaseStatusType() { Code = "C2", Description = "Desc2" }); cache.AddToDictionary(newList); List <CaseStatusType> dictList = (List <CaseStatusType>)cache.CodeTableDictionary[typeof(CaseStatusType)]; Assert.AreEqual(2, dictList.Count(), "There isn't two items."); Assert.IsNotNull(dictList.FirstOrDefault(c => c.Code == "C"), "Code C was not in the list"); Assert.IsNotNull(dictList.FirstOrDefault(c => c.Code == "C2"), "Code C2 was not in the list"); }
public void ClearCacheTest() { CodeTableCache cache = new CodeTableCache(); List <CaseType> typeList = new List <CaseType>(); typeList.Add(new CaseType() { Code = "C", Description = "Desc" }); typeList.Add(new CaseType() { Code = "C2", Description = "Desc2" }); cache.CodeTableDictionary.Add(typeof(CaseType), typeList); List <CaseType> cachedList = cache.QueryCacheCodeTable <CaseType>(CodeLookupHelper.ALL_CODES_QUERY); Assert.AreEqual(2, cachedList.Count(), "Initial count was not 2"); cache.ClearCache <CaseType>(); cachedList = cache.QueryCacheCodeTable <CaseType>(CodeLookupHelper.ALL_CODES_QUERY); Assert.AreEqual(0, cachedList.Count(), "Count was not 0 after clearing."); }
public void QueryCacheCodeTableTest_NotInDictionary() { CodeTableCache cache = new CodeTableCache(); List <CaseType> ct = cache.QueryCacheCodeTable <CaseType>("1==1"); Assert.IsNotNull(ct, "Returned list was null."); Assert.AreEqual(0, ct.Count(), "There should not be any rows"); }
public void ClearCache_TypeNotInDictionary() { CodeTableCache cache = new CodeTableCache(); cache.ClearCache <CaseType>(); List <CaseType> cachedList = cache.QueryCacheCodeTable <CaseType>(CodeLookupHelper.ALL_CODES_QUERY); Assert.AreEqual(0, cachedList.Count(), "Count was not 0 after clearing."); }
public void QueryCacheCodeTableTest() { CodeTableCache cache = new CodeTableCache(); List <CaseStatusType> csList = new List <CaseStatusType>(); csList.Add(new CaseStatusType() { Code = "C", Description = "Desc" }); cache.AddToDictionary(csList); List <CaseStatusType> result = cache.QueryCacheCodeTable <CaseStatusType>("1==1"); Assert.AreEqual(1, result.Count(), "Result did not have one item"); Assert.IsNotNull(result.FirstOrDefault(ct => ct.Code == "C"), "Result did not have the right data"); }
public void AddToDictionaryTest() { CodeTableCache cache = new CodeTableCache(); List <CaseStatusType> csList = new List <CaseStatusType>(); csList.Add(new CaseStatusType() { Code = "C", Description = "Desc" }); Assert.IsFalse(cache.CodeTableDictionary.ContainsKey(typeof(CaseStatusType)), "CaseStatusType was not null to start with"); cache.AddToDictionary(csList); Assert.AreSame(csList, cache.CodeTableDictionary[typeof(CaseStatusType)], "List was not added to the dictionary"); }