public void should_read_from_cache_when_no_update_in_po_file() { var parser = new Mock<IPoFileParser>(); var expectedI18NMessages = new[] { new I18NMessage("translation key", "translation key") }; var localeEnUsMessagesPo = Path.Combine(TestHelper.GetRuntimePath(),"locale\\en-US\\messages.po"); parser.Setup(p => p.Parse(localeEnUsMessagesPo)).Returns(expectedI18NMessages.ToDictionary(d=> d.MsgId)); var i18NMessagesCache = new GenericCache<IDictionary<string, I18NMessage>>(); var actualI18NMessages = i18NMessagesCache.Get("en-US", () => parser.Object.Parse(localeEnUsMessagesPo)); VerifyResult(expectedI18NMessages, actualI18NMessages); }
public void CacheTest() { var people = new People() { Id = 1, Name = "a" }; GenericCache <People> .GetOrSet(() => people); GenericCache <People> .Set(people); GenericCache <People> .Get(); }
private static void SimpleValidation() { // Create cache GenericCache <long, string> toStringCache = new GenericCache <long, string>( CacheFactory.Build <string>( settings => settings .WithProtoBufSerializer() .WithSQLiteCacheHandle(new SQLiteCacheHandleAdditionalConfiguration { DatabaseFilePath = "MyDatabase.sqlite" }) .Build())); // Initial state toStringCache.Exists(1).Should().BeFalse(); // Add toStringCache.Add(1, "1").Should().BeTrue(); toStringCache.Exists(1).Should().BeTrue(); // Get toStringCache.Get(1).Should().Be("1"); }
public DataTable Get(string key) { object o = genericCache.Get(key); return((o == null) ? null : (DataTable)o); }