예제 #1
0
        public async Task InitializeAsyncLoadsValuesIntoCache()
        {
            var testCache = new InMemoryBlobCache();
            await testCache.InsertObject("Storage:DummyNumber", 16);
            await testCache.InsertObject("Storage:DummyText", "Random");

            var cache = Substitute.For<IBlobCache>();
            cache.Get(Arg.Any<string>()).Returns(x => testCache.Get(x.Arg<string>()));
            var settings = new DummySettingsStorage("Storage", cache);

            await settings.InitializeAsync();

            int number = settings.DummyNumber;
            string text = settings.DummyText;

            Assert.Equal(16, number);
            Assert.Equal("Random", text);
            cache.ReceivedWithAnyArgs(2).Get(Arg.Any<string>());
        }
예제 #2
0
        public async Task InitializeAsyncLoadsValuesIntoCache()
        {
            var testCache = new InMemoryBlobCache();
            await testCache.InsertObject("Storage:DummyNumber", 16);

            await testCache.InsertObject("Storage:DummyText", "Random");

            var cache = Substitute.For <IBlobCache>();

            cache.Get(Arg.Any <string>()).Returns(x => testCache.Get(x.Arg <string>()));
            var settings = new DummySettingsStorage("Storage", cache);

            await settings.InitializeAsync();

            int    number = settings.DummyNumber;
            string text   = settings.DummyText;

            Assert.Equal(16, number);
            Assert.Equal("Random", text);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            cache.ReceivedWithAnyArgs(2).Get(Arg.Any <string>());
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
        }