public async Task GetFileDataAsyncCallsCorrectMethodsTest()
        {
            var mockHttpClient = new Mock<IRestClient>();

            var filesPersistenceClient = new FilesPersistenceClient(mockHttpClient.Object);

            await filesPersistenceClient.GetFileDataAsync<TestResponseClass>(Guid.NewGuid());
            mockHttpClient.Verify(m => m.GetItemAsync<TestResponseClass>(It.IsAny<string>()), Times.Once());
        }
        public async Task RemoveFileDataAsyncCallsCorrectMethodsTest()
        {
            var mockHttpClient = new Mock<IRestClient>();

            var formsPersistenceClient = new FilesPersistenceClient(mockHttpClient.Object);

            await formsPersistenceClient.RemoveFileDataAsync(Guid.NewGuid());
            mockHttpClient.Verify(m => m.DeleteItemAsync(It.IsAny<string>()), Times.Once());
        }
        public async Task GetFileDataAsyncCallsCorrectMethodsTest()
        {
            var mockHttpClient = new Mock <IRestClient>();

            var filesPersistenceClient = new FilesPersistenceClient(mockHttpClient.Object);

            await filesPersistenceClient.GetFileDataAsync <TestResponseClass>(Guid.NewGuid());

            mockHttpClient.Verify(m => m.GetItemAsync <TestResponseClass>(It.IsAny <string>()), Times.Once());
        }
Esempio n. 4
0
        public async Task RemoveFileDataAsyncCallsCorrectMethodsTest()
        {
            var mockHttpClient = new Mock <IRestClient>();

            var formsPersistenceClient = new FilesPersistenceClient(mockHttpClient.Object);

            await formsPersistenceClient.RemoveFileDataAsync(Guid.NewGuid());

            mockHttpClient.Verify(m => m.DeleteItemAsync(It.IsAny <string>()), Times.Once());
        }
        public async Task GetFileDataAsyncReturnsCorrectObjectTest()
        {
            var responseClass = new TestResponseClass();
            var mockHttpClient = new Mock<IRestClient>();
            mockHttpClient.Setup(x => x.GetItemAsync<TestResponseClass>(It.IsAny<string>())).Returns(Task.FromResult(responseClass));
            
            var filesPersistenceClient = new FilesPersistenceClient(mockHttpClient.Object);
            var result = await filesPersistenceClient.GetFileDataAsync<TestResponseClass>(Guid.NewGuid());

            Assert.AreEqual(responseClass, result);
        }
        public async Task GetFileDataAsyncReturnsCorrectObjectTest()
        {
            var responseClass  = new TestResponseClass();
            var mockHttpClient = new Mock <IRestClient>();

            mockHttpClient.Setup(x => x.GetItemAsync <TestResponseClass>(It.IsAny <string>())).Returns(Task.FromResult(responseClass));

            var filesPersistenceClient = new FilesPersistenceClient(mockHttpClient.Object);
            var result = await filesPersistenceClient.GetFileDataAsync <TestResponseClass>(Guid.NewGuid());

            Assert.AreEqual(responseClass, result);
        }
        public async Task SaveFileDataAsyncCallsCorrectMethodsTest()
        {
            var mockWebApiClient = new Mock<IRestClient>();

            var filesPersistenceClient = new FilesPersistenceClient(mockWebApiClient.Object);

            var byteArray = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
            var testRequest = new TestRequestClass { Bytes = byteArray, ContentType = "img", FileName = "MyTest.img" };

            await filesPersistenceClient.SaveFileDataAsync<TestRequestClass, TestResponseClass>(testRequest);
            mockWebApiClient.Verify(m => m.PostItemAsync<TestRequestClass, TestResponseClass>(It.IsAny<string>(), It.IsAny<TestRequestClass>()), Times.Once());
        }
Esempio n. 8
0
        public async Task SaveFileDataAsyncCallsCorrectMethodsTest()
        {
            var mockWebApiClient = new Mock <IRestClient>();

            var filesPersistenceClient = new FilesPersistenceClient(mockWebApiClient.Object);

            var byteArray   = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
            var testRequest = new TestRequestClass {
                Bytes = byteArray, ContentType = "img", FileName = "MyTest.img"
            };

            await filesPersistenceClient.SaveFileDataAsync <TestRequestClass, TestResponseClass>(testRequest);

            mockWebApiClient.Verify(m => m.PostItemAsync <TestRequestClass, TestResponseClass>(It.IsAny <string>(), It.IsAny <TestRequestClass>()), Times.Once());
        }