예제 #1
0
        public void SetConfigSavesDataToCache()
        {
            // Arrange
            const string newCacheData    = "SomeData";
            var          newCacheItemKey = Guid.NewGuid().ToString();

            // Act
            configCacheProvider.SetConfig(newCacheItemKey, newCacheData);

            // Assert
            var cacheResult = JsonConvert.DeserializeObject(configCacheProvider.GetConfig(newCacheItemKey));

            Assert.Equal(newCacheData, cacheResult);

            var cacheResultForDefaultValue = configCacheProvider.GetConfig(SimpleObjectKey);

            Assert.True(!string.IsNullOrEmpty(cacheResultForDefaultValue));
        }
예제 #2
0
        public void SetConfigSavesDataToCacheWithoutDefaultValues()
        {
            // Arrange
            const string newCacheData    = "OnlyItemOfData";
            var          newCacheItemKey = Guid.NewGuid().ToString();
            var          cacheProvider   = new InMemorySharedConfigCacheProvider(settings);

            // Act
            cacheProvider.SetConfig(newCacheItemKey, newCacheData);

            // Assert
            var cacheResult = JsonConvert.DeserializeObject(cacheProvider.GetConfig(newCacheItemKey));

            Assert.Equal(newCacheData, cacheResult);

            var cacheResultForDefaultValue = JsonConvert.DeserializeObject(cacheProvider.GetConfig(SingleValueKey));

            Assert.Null(cacheResultForDefaultValue);
        }