Example #1
0
        public async Task ProcessQuery_QueryIsNotCacheInfo_ShouldReturnCorrectValue(
            [Frozen] Mock <IAsyncQueryBus> queryBus,
            IAsyncQuery <object> query,
            object expected,
            CacheAsyncQueryBus sut)
        {
            //arrange
            queryBus.Setup(q => q.ProcessQuery <IAsyncQuery <object>, object>(query)).ReturnsTask(expected);

            //act
            var actual = await sut.ProcessQuery <IAsyncQuery <object>, object>(query);

            //assert
            actual.Should().Be(expected);
        }
Example #2
0
		public async Task ProcessQuery_QueryIsNotCacheInfo_ShouldReturnCorrectValue(
			[Frozen]Mock<IAsyncQueryBus> queryBus,
			IAsyncQuery<object> query,
			object expected,
			CacheAsyncQueryBus sut)
		{
			//arrange
			queryBus.Setup(q => q.ProcessQuery<IAsyncQuery<object>, object>(query)).ReturnsTask(expected);

			//act
			var actual = await sut.ProcessQuery<IAsyncQuery<object>, object>(query);

			//assert
			actual.Should().Be(expected);
		}
Example #3
0
        public async Task ProcessQuery_QueryIsCacheInfo_ShouldReturnCorrectValue(
            [Frozen] TimeSpan defaultAge,
            [Frozen] Mock <ICacheService> cacheService,
            CacheAsyncQueryBus sut,
            Mock <IAsyncQuery <object> > query,
            TimeSpan cacheAge,
            string key,
            IDictionary <string, string> attributes,
            object expected,
            object notExpected)
        {
            //arrange
            query.As <ICacheInfos>().Setup(c => c.Attributes).Returns(attributes);
            query.As <ICacheInfos>().Setup(c => c.Key).Returns(key);
            query.Setup(c => c.CancellationToken).Returns(CancellationToken.None);
            cacheService.Setup(c => c.ExecuteWithCache(It.IsAny <CancellationToken>(), key, It.IsAny <Func <Task <object> > >(), defaultAge, attributes))
            .ReturnsTask(expected);

            //act
            var actual = await sut.ProcessQuery <IAsyncQuery <object>, object>(query.Object);

            //assert
            actual.Should().Be(expected);
        }
Example #4
0
		public async Task ProcessQuery_QueryIsCacheInfo_ShouldReturnCorrectValue(
			[Frozen]TimeSpan defaultAge,
			[Frozen]Mock<ICacheService> cacheService,
			CacheAsyncQueryBus sut,
			Mock<IAsyncQuery<object>> query,
			TimeSpan cacheAge,
			string key,
			IDictionary<string, string> attributes,
			object expected,
			object notExpected)
		{
			//arrange
			query.As<ICacheInfos>().Setup(c => c.Attributes).Returns(attributes);
			query.As<ICacheInfos>().Setup(c => c.Key).Returns(key);
			query.Setup(c => c.CancellationToken).Returns(CancellationToken.None);
			cacheService.Setup(c => c.ExecuteWithCache(It.IsAny<CancellationToken>(), key, It.IsAny<Func<Task<object>>>(), defaultAge, attributes))
						.ReturnsTask(expected);

			//act
			var actual = await sut.ProcessQuery<IAsyncQuery<object>, object>(query.Object);

			//assert
			actual.Should().Be(expected);
		}