コード例 #1
0
        private void LoadValuesIntoCache()
        {
            if (_memoryCacheService.GetCount() == 0)
            {
                var config = _fileManager.ReadAllEntriesFromFile();

                foreach (var item in config)
                {
                    _memoryCacheService.Add(item);
                }
            }
        }
コード例 #2
0
        public void ConfigurationManager_WhenCreated_PopulatesConfigItemListFromFile()
        {
            // Arrange
            var configItems = new List <IConfigItem>()
            {
                new ConfigItem("key1", "value1"),
                new ConfigItem("key2", "value2"),
                new ConfigItem("key3", "value3"),
            };

            _memoryCacheService.GetCount().Returns(0);
            _fileManager.ReadAllEntriesFromFile().Returns(configItems);

            // Act
            _configurationService = new ConfigurationService(_fileManager, _memoryCacheService);


            // Assert
            _memoryCacheService.Received(1).Add(configItems[0]);
            _memoryCacheService.Received(1).Add(configItems[1]);
            _memoryCacheService.Received(1).Add(configItems[2]);
        }