public void LoadAsyncUriWebTest(int blockSize) { var server = FluentMockServer.Start(); server .Given( Requests.WithUrl(string.Format("/{0}", _testFile)) ) .RespondWith( Responses .WithStatusCode(200) .WithBody(TestDocument) ); SetupRepoMock(); var loader = new DocumentLoaderAsync(_repo, blockSize); var awaiter = Task.Run(async () => await loader.LoadAsync(new Uri(string.Format("http://localhost:{0}/{1}", server.Port, _testFile))).ConfigureAwait(false)); var result = awaiter.Result; Assert.IsTrue(result); CheckRepoMock(); }
public void LoadAsyncStreamTest(int blockSize) { SetupRepoMock(); var loader = new DocumentLoaderAsync(_repo, blockSize); var data = new MemoryStream(Encoding.UTF8.GetBytes(TestDocument)); var awaiter = Task.Run(async () => await loader.LoadAsync(data, "text/plain").ConfigureAwait(false)); var result = awaiter.Result; Assert.IsTrue(result); CheckRepoMock(); }
public void LoadAsyncUriFileTest(int blockSize) { CreateFile(_testFile, TestDocument); SetupRepoMock(); var loader = new DocumentLoaderAsync(_repo, blockSize); var testPath = Path.GetFullPath(_testFile); var awaiter = Task.Run(async () => await loader.LoadAsync(new Uri(string.Format("file:///{0}", testPath))).ConfigureAwait(false)); var result = awaiter.Result; Assert.IsTrue(result); CheckRepoMock(); }
public void LoadAsyncFileTest(int blockSize) { CreateFile(_testFile, TestDocument); SetupRepoMock(); var loader = new DocumentLoaderAsync(_repo, blockSize); var awaiter = Task.Run(async () => await loader.LoadAsync(_testFile).ConfigureAwait(false)); var result = awaiter.Result; Assert.IsTrue(result); CheckRepoMock(); }