public void DeserializeEnum_WithDefaultCache_EnumAddedToCache() { lock (StaticTestingLocks.DeserializeCacheLockObject) { PrettyEnumHelpers <FakeTestingEnum> .DeserializeCache = new ConcurrentDictionary <string, FakeTestingEnum>(); const int YourvalueInt = 123; FakeTestingEnum yourvalueEnum = PrettyEnumHelpers <FakeTestingEnum> .GetEnumFrom(YourvalueInt.ToString()); Assert.Equal(FakeTestingEnum.YourValue, yourvalueEnum); Assert.Equal(1, PrettyEnumHelpers <FakeTestingEnum> .DeserializeCache.Count); Assert.True( PrettyEnumHelpers <FakeTestingEnum> .DeserializeCache.ContainsKey(YourvalueInt.ToString())); } }
public void DeserializeEnum_WithCache_EnumsAddedToCache() { const int YourvalueInt = 123; const int MyValueInt = 99; var cache = new ConcurrentDictionary <string, FakeTestingEnum>(); FakeTestingEnum yourvalueEnum = PrettyEnumHelpers <FakeTestingEnum> .DeserializeEnum(YourvalueInt.ToString(), cache); FakeTestingEnum myvalueEnum = PrettyEnumHelpers <FakeTestingEnum> .DeserializeEnum( MyValueInt.ToString(), cache); Assert.Equal(FakeTestingEnum.YourValue, yourvalueEnum); Assert.Equal(FakeTestingEnum.MyValue, myvalueEnum); Assert.Equal(2, cache.Count); Assert.True(cache.ContainsKey(YourvalueInt.ToString())); Assert.True(cache.ContainsKey(MyValueInt.ToString())); }