コード例 #1
0
        public void GetById_Failure()
        {
            var mockDictionaryValue = TestData.pendingExecution;
            Dictionary <int, Execution> mockDictionary = new Dictionary <int, Execution>();

            mockDictionary.Add(mockDictionaryValue.Id, mockDictionaryValue);
            object mockOutValue = mockDictionary;

            mockCache.Setup(x => x.TryGetValue(It.IsAny <string>(), out mockOutValue)).Returns(false);

            var instance = new MergeSortCaching(mockCache.Object, mockLogger.Object);

            Assert.ThrowsAsync <JobNotFoundException>(() => instance.GetById(5));
        }
コード例 #2
0
        public async Task GetById_Success()
        {
            var mockDictionaryValue = TestData.pendingExecution;
            Dictionary <int, Execution> mockDictionary = new Dictionary <int, Execution>();

            mockDictionary.Add(mockDictionaryValue.Id, mockDictionaryValue);
            object mockOutValue = mockDictionary;

            mockCache.Setup(x => x.TryGetValue(It.IsAny <string>(), out mockOutValue)).Returns(true);

            var instance = new MergeSortCaching(mockCache.Object, mockLogger.Object);
            var result   = await instance.GetById(5);

            mockDictionaryValue.Should().BeEquivalentTo(result);
        }