public void FetchRemoteRepositoryModelDoesNotExist() { string targetDtmi = "dtmi:com:example:thermojax;1"; RemoteModelFetcher remoteFetcher = new RemoteModelFetcher(_logger.Object, new ResolverClientOptions()); Assert.ThrowsAsync <RequestFailedException>(async() => await remoteFetcher.FetchAsync(targetDtmi, _remoteUri)); }
public void FetchRemoteRepositoryDoesNotExist() { string targetDtmi = "dtmi:com:example:thermostat;1"; Uri invalidRemoteUri = new Uri("https://localhost:80/fakeRepo/"); RemoteModelFetcher remoteFetcher = new RemoteModelFetcher(_logger.Object, new ResolverClientOptions()); Assert.ThrowsAsync <AggregateException>(async() => await remoteFetcher.FetchAsync(targetDtmi, invalidRemoteUri)); }
// [TestCase(true)] - TODO: Uncomment when consistent remote repo available. public async Task FetchRemoteRepository(bool fetchExpanded) { string targetDtmi = "dtmi:com:example:temperaturecontroller;1"; RemoteModelFetcher remoteFetcher = new RemoteModelFetcher(_logger.Object, new ResolverClientOptions()); string expectedPath = DtmiConventions.DtmiToQualifiedPath(targetDtmi, _remoteUri.AbsoluteUri, fetchExpanded); string fetcherPath = remoteFetcher.GetPath(targetDtmi, _remoteUri, fetchExpanded); Assert.AreEqual(fetcherPath, expectedPath); // Resolution correctness is covered in ResolverIntegrationTests FetchResult fetchResult = await remoteFetcher.FetchAsync(targetDtmi, _remoteUri); Assert.True(!string.IsNullOrEmpty(fetchResult.Definition)); Assert.True(!string.IsNullOrEmpty(fetchResult.Path)); Assert.AreEqual(fetchResult.FromExpanded, fetchExpanded); _logger.ValidateLog($"{StandardStrings.FetchingContent(fetcherPath)}", LogLevel.Trace, Times.Once()); }