コード例 #1
0
		public async Task Get_WhenValueIsUpdated_ShouldReturnCorrectValue(
			MemoryCacheEntryRepository sut,
			CacheEntry<object> cacheEntry,
			object newValue)
		{
			//arrange
			var expected = new CacheEntry<object>(cacheEntry.Id, cacheEntry.CacheKey, cacheEntry.Attributes, DateTimeOffset.Now, newValue);
			await sut.AddOrUpdate(CancellationToken.None, cacheEntry);
			await sut.AddOrUpdate(CancellationToken.None, expected);

			//act
			var actual = await sut.Get<object>(CancellationToken.None, expected.CacheKey, expected.Attributes);

			//assert
			actual.Should().Be(expected);
		}
コード例 #2
0
        public async Task Get_WhenValueIsUpdated_ShouldReturnCorrectValue(
            MemoryCacheEntryRepository sut,
            CacheEntry <object> cacheEntry,
            object newValue)
        {
            //arrange
            var expected = new CacheEntry <object>(cacheEntry.Id, cacheEntry.CacheKey, cacheEntry.Attributes, DateTimeOffset.Now, newValue);
            await sut.AddOrUpdate(CancellationToken.None, cacheEntry);

            await sut.AddOrUpdate(CancellationToken.None, expected);

            //act
            var actual = await sut.Get <object>(CancellationToken.None, expected.CacheKey, expected.Attributes);

            //assert
            actual.Should().Be(expected);
        }
コード例 #3
0
		public async Task Get_WhenValueExists_ShouldReturnCorrectValue(
			MemoryCacheEntryRepository sut,
			[Frozen]Dictionary<string, string> attributes,
			[Frozen]string cacheKey,
			[Frozen]Guid id,
			CacheEntry<object> expected)
		{
			//arrange
			await sut.AddOrUpdate(CancellationToken.None, expected);

			//act
			var actual = await sut.Get<object>(CancellationToken.None, expected.CacheKey, expected.Attributes);

			//assert
			actual.Should().Be(expected);
		}
コード例 #4
0
        public async Task Get_AfterRemoving_ShouldReturnCorrectValue(
            MemoryCacheEntryRepository sut,
            CacheEntry <object> cacheEntry,
            object newValue)
        {
            //arrange
            await sut.AddOrUpdate(CancellationToken.None, cacheEntry);

            await sut.Remove <CacheEntry <object> >(CancellationToken.None, cacheEntry.CacheKey, cacheEntry.Id);

            //act
            var actual = await sut.Get <object>(CancellationToken.None, cacheEntry.CacheKey, cacheEntry.Attributes);

            //assert
            actual.Should().BeNull();
        }
コード例 #5
0
        public async Task Get_WhenValueExists_ShouldReturnCorrectValue(
            MemoryCacheEntryRepository sut,
            [Frozen] Dictionary <string, string> attributes,
            [Frozen] string cacheKey,
            [Frozen] Guid id,
            CacheEntry <object> expected)
        {
            //arrange
            await sut.AddOrUpdate(CancellationToken.None, expected);

            //act
            var actual = await sut.Get <object>(CancellationToken.None, expected.CacheKey, expected.Attributes);

            //assert
            actual.Should().Be(expected);
        }
コード例 #6
0
		public async Task Get_AfterRemoving_ShouldReturnCorrectValue(
		MemoryCacheEntryRepository sut,
		CacheEntry<object> cacheEntry,
		object newValue)
		{
			//arrange			
			await sut.AddOrUpdate(CancellationToken.None, cacheEntry);
			await sut.Remove<CacheEntry<object>>(CancellationToken.None, cacheEntry.CacheKey, cacheEntry.Id);

			//act
			var actual = await sut.Get<object>(CancellationToken.None, cacheEntry.CacheKey, cacheEntry.Attributes);

			//assert
			actual.Should().BeNull();
		}