示例#1
0
        public async Task OpenRead()
        {
            string key        = "key";
            var    mockStream = new Mock <Stream>();

            this.mockStorageProvider.Setup(p => p.OpenReadStreamAsync(key, this.config)).ReturnsAsync(mockStream.Object);

            var file = new TestCabinetFileInfo(key, true, ItemType.File)
            {
                ProviderType = TestProviderType
            };

            var stream = await this.fileCabinet.OpenReadStreamAsync(file.Key);

            this.mockStorageProvider.Verify(p => p.OpenReadStreamAsync(key, this.config), Times.Once);

            Assert.Equal(mockStream.Object, stream);
        }
        public async Task Get_File(string key, bool existsInTo, bool existsInFrom) {
            var toItem = new TestCabinetFileInfo(key, existsInTo, ItemType.File);
            var fromItem = new TestCabinetFileInfo(key, existsInFrom, ItemType.File);

            this.mockToCabinet.Setup(c => c.GetItemAsync(key)).ReturnsAsync(toItem);
            this.mockFromCabinet.Setup(c => c.GetItemAsync(key)).ReturnsAsync(fromItem);

            var item = await provider.GetItemAsync(key, config);

            this.mockToCabinet.Verify(c => c.GetItemAsync(key), Times.Once);
            this.mockFromCabinet.Verify(c => c.GetItemAsync(key), existsInTo ? Times.Never() : Times.Once());

            if(existsInTo) {
                Assert.Equal(toItem, item);
            } else {
                Assert.Equal(fromItem, item);
            }
        }
        public async Task Get_File(string key, bool exists) {
            var exectedItem = new TestCabinetFileInfo(key, exists, ItemType.File);
            
            this.mockMasterCabinet.Setup(c => c.GetItemAsync(key)).ReturnsAsync(exectedItem);

            var item = await provider.GetItemAsync(key, config);

            this.mockMasterCabinet.Verify(c => c.GetItemAsync(key), Times.Once);
            this.mockReplicaCabinet.Verify(c => c.GetItemAsync(key), Times.Never);

            Assert.Equal(exectedItem, item);
        }
示例#4
0
        public async Task OpenRead() {
            string key = "key";
            var mockStream = new Mock<Stream>();

            this.mockStorageProvider.Setup(p => p.OpenReadStreamAsync(key, this.config)).ReturnsAsync(mockStream.Object);

            var file = new TestCabinetFileInfo(key, true, ItemType.File) {
                ProviderType = TestProviderType
            };

            var stream = await this.fileCabinet.OpenReadStreamAsync(file.Key);

            this.mockStorageProvider.Verify(p => p.OpenReadStreamAsync(key, this.config), Times.Once);

            Assert.Equal(mockStream.Object, stream);
        }