コード例 #1
0
        public async Task Get_WhenValueDoesNotExists_ShouldReturnCorrectValue(
            MemoryCacheEntryRepository sut,
            string cacheKey,
            Dictionary <string, string> attributes)
        {
            //arrange

            //act
            var actual = await sut.Get <object>(CancellationToken.None, cacheKey, attributes);

            //assert
            actual.Should().BeNull();
        }
コード例 #2
0
		public async Task Get_WhenValueDoesNotExists_ShouldReturnCorrectValue(
			MemoryCacheEntryRepository sut,
			string cacheKey,
			Dictionary<string, string> attributes)
		{
			//arrange

			//act
			var actual = await sut.Get<object>(CancellationToken.None, cacheKey, attributes);

			//assert
			actual.Should().BeNull();
		}
コード例 #3
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);
		}
コード例 #4
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);
		}
コード例 #5
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();
        }
コード例 #6
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);
        }
コード例 #7
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);
        }
コード例 #8
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();
		}
コード例 #9
0
		public void Sut_IsCacheEntryRepository(MemoryCacheEntryRepository sut)
		{
			sut.Should().BeAssignableTo<ICacheEntryRepository>();
		}
コード例 #10
0
 public void Sut_IsCacheEntryRepository(MemoryCacheEntryRepository sut)
 {
     sut.Should().BeAssignableTo <ICacheEntryRepository>();
 }