diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/Azure.Iot.ModelsRepository.sln b/sdk/modelsrepository/Azure.Iot.ModelsRepository/Azure.Iot.ModelsRepository.sln
index 68ee35711decf..cefb388cba6f6 100644
--- a/sdk/modelsrepository/Azure.Iot.ModelsRepository/Azure.Iot.ModelsRepository.sln
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/Azure.Iot.ModelsRepository.sln
@@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Iot.ModelsRepository.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{1FC8A3EA-3C0D-4DDF-B710-A7091F2CEBB1}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModelsRepositoryClientSamples", "samples\ModelsRepositoryClientSamples\ModelsRepositoryClientSamples.csproj", "{51E4AB9E-46F3-450C-B52A-C4C6378E8BA3}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -27,6 +29,10 @@ Global
{1FC8A3EA-3C0D-4DDF-B710-A7091F2CEBB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1FC8A3EA-3C0D-4DDF-B710-A7091F2CEBB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1FC8A3EA-3C0D-4DDF-B710-A7091F2CEBB1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {51E4AB9E-46F3-450C-B52A-C4C6378E8BA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {51E4AB9E-46F3-450C-B52A-C4C6378E8BA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {51E4AB9E-46F3-450C-B52A-C4C6378E8BA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {51E4AB9E-46F3-450C-B52A-C4C6378E8BA3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/samples/ModelsRepositoryClientSamples/ModelsRepositoryClientSamples.csproj b/sdk/modelsrepository/Azure.Iot.ModelsRepository/samples/ModelsRepositoryClientSamples/ModelsRepositoryClientSamples.csproj
new file mode 100644
index 0000000000000..9b97b1c529cee
--- /dev/null
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/samples/ModelsRepositoryClientSamples/ModelsRepositoryClientSamples.csproj
@@ -0,0 +1,21 @@
+
+
+
+ Exe
+ netcoreapp3.1;net5.0
+
+
+
+ Exe
+ netcoreapp3.1;net5.0
+ Azure.Iot.ModelsRepository.Samples
+
+
+
+
+
+
+
+
+
+
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/samples/ModelsRepositoryClientSamples/Program.cs b/sdk/modelsrepository/Azure.Iot.ModelsRepository/samples/ModelsRepositoryClientSamples/Program.cs
new file mode 100644
index 0000000000000..a1e14466d2cd0
--- /dev/null
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/samples/ModelsRepositoryClientSamples/Program.cs
@@ -0,0 +1,52 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using Azure.Core.Diagnostics;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.Tracing;
+using System.Net;
+using System.Threading.Tasks;
+
+namespace Azure.Iot.ModelsRepository.Samples
+{
+ public class Program
+ {
+ public static async Task Main(string[] args)
+ {
+ // Forward all the events written to the console output with a specific format.
+ using AzureEventSourceListener listener = new AzureEventSourceListener(
+ (e, message) => Console.WriteLine("[{0:HH:mm:ss:fff}][{1}] {2}", DateTimeOffset.Now, e.Level, message),
+ level: EventLevel.Verbose);
+
+ await ResolveExistingAsync();
+ await TryResolveButNotFoundAsync();
+ }
+
+ private static async Task ResolveExistingAsync()
+ {
+ var dtmi = "dtmi:com:example:TemperatureController;1";
+ var client = new ModelsRepositoryClient();
+
+ IDictionary models = await client.ResolveAsync(dtmi).ConfigureAwait(false);
+
+ Console.WriteLine($"{dtmi} resolved in {models.Count} interfaces.");
+ }
+
+ private static async Task TryResolveButNotFoundAsync()
+ {
+ var dtmi = "dtmi:com:example:NotFound;1";
+ var client = new ModelsRepositoryClient();
+
+ try
+ {
+ IDictionary models = await client.ResolveAsync(dtmi).ConfigureAwait(false);
+ Console.WriteLine($"{dtmi} resolved in {models.Count} interfaces.");
+ }
+ catch (RequestFailedException ex) when (ex.Status == (int)HttpStatusCode.NotFound)
+ {
+ Console.WriteLine($"{dtmi} was not found in the default public models repository: {ex.Message}");
+ }
+ }
+ }
+}
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/samples/readme.md b/sdk/modelsrepository/Azure.Iot.ModelsRepository/samples/readme.md
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/Fetchers/LocalModelFetcher.cs b/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/Fetchers/LocalModelFetcher.cs
index 1125d201e31db..95cc557df7e9b 100644
--- a/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/Fetchers/LocalModelFetcher.cs
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/Fetchers/LocalModelFetcher.cs
@@ -21,7 +21,7 @@ internal class LocalModelFetcher : IModelFetcher
private readonly bool _tryExpanded;
private readonly ClientDiagnostics _clientDiagnostics;
- public LocalModelFetcher(ClientDiagnostics clientDiagnostics, ModelsRepoClientOptions clientOptions)
+ public LocalModelFetcher(ClientDiagnostics clientDiagnostics, ModelsRepositoryClientOptions clientOptions)
{
_clientDiagnostics = clientDiagnostics;
_tryExpanded = clientOptions.DependencyResolution == DependencyResolutionOption.TryFromExpanded;
@@ -54,7 +54,7 @@ public FetchResult Fetch(string dtmi, Uri repositoryUri, CancellationToken cance
cancellationToken.ThrowIfCancellationRequested();
string tryContentPath = work.Dequeue();
- ModelsRepoEventSource.Instance.FetchingModelContent(tryContentPath);
+ ModelsRepositoryEventSource.Instance.FetchingModelContent(tryContentPath);
if (File.Exists(tryContentPath))
{
@@ -65,7 +65,7 @@ public FetchResult Fetch(string dtmi, Uri repositoryUri, CancellationToken cance
};
}
- ModelsRepoEventSource.Instance.ErrorFetchingModelContent(tryContentPath);
+ ModelsRepositoryEventSource.Instance.ErrorFetchingModelContent(tryContentPath);
fnfError = string.Format(CultureInfo.CurrentCulture, ServiceStrings.ErrorFetchingModelContent, tryContentPath);
}
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/Fetchers/RemoteModelFetcher.cs b/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/Fetchers/RemoteModelFetcher.cs
index 9018561dcb185..1effcc42ca075 100644
--- a/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/Fetchers/RemoteModelFetcher.cs
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/Fetchers/RemoteModelFetcher.cs
@@ -7,6 +7,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
+using System.Net;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
@@ -23,7 +24,7 @@ internal class RemoteModelFetcher : IModelFetcher
private readonly ClientDiagnostics _clientDiagnostics;
private readonly bool _tryExpanded;
- public RemoteModelFetcher(ClientDiagnostics clientDiagnostics, ModelsRepoClientOptions clientOptions)
+ public RemoteModelFetcher(ClientDiagnostics clientDiagnostics, ModelsRepositoryClientOptions clientOptions)
{
_pipeline = CreatePipeline(clientOptions);
_tryExpanded = clientOptions.DependencyResolution == DependencyResolutionOption.TryFromExpanded;
@@ -45,7 +46,7 @@ public FetchResult Fetch(string dtmi, Uri repositoryUri, CancellationToken cance
cancellationToken.ThrowIfCancellationRequested();
string tryContentPath = work.Dequeue();
- ModelsRepoEventSource.Instance.FetchingModelContent(tryContentPath);
+ ModelsRepositoryEventSource.Instance.FetchingModelContent(tryContentPath);
try
{
@@ -82,13 +83,15 @@ public async Task FetchAsync(string dtmi, Uri repositoryUri, Cancel
Queue work = PrepareWork(dtmi, repositoryUri);
string remoteFetchError = string.Empty;
+ RequestFailedException requestFailedExceptionThrown = null;
+ Exception genericExceptionThrown = null;
while (work.Count != 0)
{
cancellationToken.ThrowIfCancellationRequested();
string tryContentPath = work.Dequeue();
- ModelsRepoEventSource.Instance.FetchingModelContent(tryContentPath);
+ ModelsRepositoryEventSource.Instance.FetchingModelContent(tryContentPath);
try
{
@@ -99,7 +102,16 @@ public async Task FetchAsync(string dtmi, Uri repositoryUri, Cancel
Path = tryContentPath
};
}
- catch (Exception)
+ catch (RequestFailedException ex)
+ {
+ requestFailedExceptionThrown = ex;
+ }
+ catch (Exception ex)
+ {
+ genericExceptionThrown = ex;
+ }
+
+ if (genericExceptionThrown != null || requestFailedExceptionThrown != null)
{
remoteFetchError =
$"{string.Format(CultureInfo.CurrentCulture, ServiceStrings.GenericResolverError, dtmi)} " +
@@ -107,7 +119,22 @@ public async Task FetchAsync(string dtmi, Uri repositoryUri, Cancel
}
}
- throw new RequestFailedException(remoteFetchError);
+ if (requestFailedExceptionThrown != null)
+ {
+ throw new RequestFailedException(
+ requestFailedExceptionThrown.Status,
+ remoteFetchError,
+ requestFailedExceptionThrown.ErrorCode,
+ requestFailedExceptionThrown);
+ }
+ else
+ {
+ throw new RequestFailedException(
+ (int)HttpStatusCode.BadRequest,
+ remoteFetchError,
+ null,
+ genericExceptionThrown);
+ }
}
catch (Exception ex)
{
@@ -219,7 +246,7 @@ private static async Task GetContentAsync(Stream content, CancellationTo
return root.GetRawText();
}
- private static HttpPipeline CreatePipeline(ModelsRepoClientOptions options)
+ private static HttpPipeline CreatePipeline(ModelsRepositoryClientOptions options)
{
return HttpPipelineBuilder.Build(options);
}
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepoClient.cs b/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepositoryClient.cs
similarity index 67%
rename from sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepoClient.cs
rename to sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepositoryClient.cs
index 717211e54eec7..7b19334beb69e 100644
--- a/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepoClient.cs
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepositoryClient.cs
@@ -6,84 +6,56 @@
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
-using Azure.Core;
using Azure.Core.Pipeline;
namespace Azure.Iot.ModelsRepository
{
///
- /// The ModelsRepoClient class supports operations against DTDL model repositories following the
+ /// The ModelsRepositoryClient class supports operations against DTDL model repositories following the
/// conventions of the Azure IoT Plug and Play Models repository.
///
- public class ModelsRepoClient
+ public class ModelsRepositoryClient
{
private readonly RepositoryHandler _repositoryHandler;
private readonly ClientDiagnostics _clientDiagnostics;
+ private readonly ModelsRepositoryClientOptions _clientOptions;
///
- /// Initializes the ModelsRepoClient with default client options while pointing to
+ /// Initializes the ModelsRepositoryClient with default client options while pointing to
/// the Azure IoT Plug and Play Models repository https://devicemodels.azure.com for resolution.
///
- public ModelsRepoClient() : this(new Uri(DefaultModelsRepository), new ModelsRepoClientOptions()) { }
+ public ModelsRepositoryClient() : this(DefaultModelsRepository, new ModelsRepositoryClientOptions()) { }
///
- /// Initializes the ModelsRepoClient with default client options while pointing to
- /// a custom for resolution.
- ///
- ///
- /// The model repository Uri value. This can be a remote endpoint or local directory.
- ///
- public ModelsRepoClient(Uri repositoryUri) : this(repositoryUri, new ModelsRepoClientOptions()) { }
-
- ///
- /// Initializes the ModelsRepoClient with custom client while pointing to
+ /// Initializes the ModelsRepositoryClient with custom client while pointing to
/// the Azure IoT Plug and Play Model repository https://devicemodels.azure.com for resolution.
///
///
- /// ModelsRepoClientOptions to configure resolution and client behavior.
+ /// ModelsRepositoryClientOptions to configure resolution and client behavior.
///
- public ModelsRepoClient(ModelsRepoClientOptions options) : this(new Uri(DefaultModelsRepository), options) { }
+ public ModelsRepositoryClient(ModelsRepositoryClientOptions options) : this(DefaultModelsRepository, options) { }
///
- /// Initializes the ModelsRepoClient with default client options while pointing to
- /// a custom for resolution.
- ///
- ///
- /// The model repository Uri in string format. This can be a remote endpoint or local directory.
- ///
- public ModelsRepoClient(string repositoryUriStr) : this(repositoryUriStr, new ModelsRepoClientOptions()) { }
-
- ///
- /// Initializes the ModelsRepoClient with custom client while pointing to
- /// a custom for resolution.
- ///
- ///
- /// The model repository Uri in string format. This can be a remote endpoint or local directory.
- ///
- ///
- /// ModelsRepoClientOptions to configure resolution and client behavior.
- ///
- public ModelsRepoClient(string repositoryUriStr, ModelsRepoClientOptions options)
- : this(new Uri(repositoryUriStr), options) { }
-
- ///
- /// Initializes the ModelsRepoClient with custom client while pointing to
+ /// Initializes the ModelsRepositoryClient with custom client while pointing to
/// a custom for resolution.
///
///
/// The model repository Uri. This can be a remote endpoint or local directory.
///
///
- /// ModelsRepoClientOptions to configure resolution and client behavior.
+ /// ModelsRepositoryClientOptions to configure resolution and client behavior.
///
- public ModelsRepoClient(Uri repositoryUri, ModelsRepoClientOptions options)
+ public ModelsRepositoryClient(Uri repositoryUri, ModelsRepositoryClientOptions options = default)
{
- Argument.AssertNotNull(options, nameof(options));
+ if (options == null)
+ {
+ options = new ModelsRepositoryClientOptions();
+ }
- ClientOptions = options;
RepositoryUri = repositoryUri;
+ _clientOptions = options;
_clientDiagnostics = new ClientDiagnostics(options);
- _repositoryHandler = new RepositoryHandler(RepositoryUri, _clientDiagnostics, ClientOptions);
+ _repositoryHandler = new RepositoryHandler(RepositoryUri, _clientDiagnostics, _clientOptions);
}
///
@@ -102,7 +74,7 @@ public ModelsRepoClient(Uri repositoryUri, ModelsRepoClientOptions options)
Justification = "")]
public virtual async Task> ResolveAsync(string dtmi, CancellationToken cancellationToken = default)
{
- using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ModelsRepoClient)}.{nameof(Resolve)}");
+ using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ModelsRepositoryClient)}.{nameof(Resolve)}");
scope.Start();
try
{
@@ -131,7 +103,7 @@ public virtual async Task> ResolveAsync(string dtmi,
Justification = "")]
public virtual IDictionary Resolve(string dtmi, CancellationToken cancellationToken = default)
{
- using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ModelsRepoClient)}.{nameof(Resolve)}");
+ using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ModelsRepositoryClient)}.{nameof(Resolve)}");
scope.Start();
try
@@ -158,7 +130,7 @@ public virtual IDictionary Resolve(string dtmi, CancellationToke
[SuppressMessage("Usage", "AZC0015:Unexpected client method return type.", Justification = "")]
public virtual async Task> ResolveAsync(IEnumerable dtmis, CancellationToken cancellationToken = default)
{
- using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ModelsRepoClient)}.{nameof(Resolve)}");
+ using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ModelsRepositoryClient)}.{nameof(Resolve)}");
scope.Start();
try
@@ -185,7 +157,7 @@ public virtual async Task> ResolveAsync(IEnumerable<
[SuppressMessage("Usage", "AZC0015:Unexpected client method return type.", Justification = "")]
public virtual IDictionary Resolve(IEnumerable dtmis, CancellationToken cancellationToken = default)
{
- using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ModelsRepoClient)}.{nameof(Resolve)}");
+ using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ModelsRepositoryClient)}.{nameof(Resolve)}");
scope.Start();
try
@@ -205,18 +177,13 @@ public virtual IDictionary Resolve(IEnumerable dtmis, Ca
public static bool IsValidDtmi(string dtmi) => DtmiConventions.IsDtmi(dtmi);
///
- /// Gets the Uri associated with the ModelsRepoClient instance.
+ /// Gets the Uri associated with the ModelsRepositoryClient instance.
///
public Uri RepositoryUri { get; }
- ///
- /// Gets the ModelsRepoClientOptions associated with the ModelsRepoClient instance.
- ///
- public ModelsRepoClientOptions ClientOptions { get; }
-
///
/// The global Azure IoT Models Repository endpoint used by default.
///
- public static string DefaultModelsRepository => ModelRepositoryConstants.DefaultModelsRepository;
+ public static Uri DefaultModelsRepository => new Uri(ModelRepositoryConstants.DefaultModelsRepository);
}
}
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepoClientOptions.cs b/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepositoryClientOptions.cs
similarity index 92%
rename from sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepoClientOptions.cs
rename to sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepositoryClientOptions.cs
index 72effaccbbd93..1382f075dcc06 100644
--- a/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepoClientOptions.cs
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepositoryClientOptions.cs
@@ -9,7 +9,7 @@ namespace Azure.Iot.ModelsRepository
///
/// Options that allow configuration of requests sent to the ModelRepositoryService.
///
- public class ModelsRepoClientOptions : ClientOptions
+ public class ModelsRepositoryClientOptions : ClientOptions
{
internal const ServiceVersion LatestVersion = ServiceVersion.V2021_02_11;
@@ -33,14 +33,14 @@ public enum ServiceVersion
public ServiceVersion Version { get; }
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
///
/// The of the service API used when
/// making requests.
///
/// The dependency processing options.
- public ModelsRepoClientOptions(
+ public ModelsRepositoryClientOptions(
ServiceVersion version = LatestVersion,
DependencyResolutionOption resolutionOption = DependencyResolutionOption.Enabled)
{
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepoEventSource.cs b/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepositoryEventSource.cs
similarity index 95%
rename from sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepoEventSource.cs
rename to sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepositoryEventSource.cs
index f6220d83e7589..db002ef02223d 100644
--- a/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepoEventSource.cs
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/ModelsRepositoryEventSource.cs
@@ -8,7 +8,7 @@
namespace Azure.Iot.ModelsRepository
{
[EventSource(Name = EventSourceName)]
- internal sealed class ModelsRepoEventSource : EventSource
+ internal sealed class ModelsRepositoryEventSource : EventSource
{
private const string EventSourceName = ModelRepositoryConstants.ModelRepositoryEventSourceName;
@@ -26,9 +26,9 @@ internal sealed class ModelsRepoEventSource : EventSource
private const int ErrorFetchingModelContentEventId = 4004;
private const int IncorrectDtmiCasingEventId = 4006;
- public static ModelsRepoEventSource Instance { get; } = new ModelsRepoEventSource();
+ public static ModelsRepositoryEventSource Instance { get; } = new ModelsRepositoryEventSource();
- private ModelsRepoEventSource()
+ private ModelsRepositoryEventSource()
: base(EventSourceName,
EventSourceSettings.Default,
AzureEventSourceListener.TraitName,
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/RepositoryHandler.cs b/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/RepositoryHandler.cs
index 55fe1717c1858..ffb16a9769459 100644
--- a/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/RepositoryHandler.cs
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/src/RepositoryHandler.cs
@@ -18,9 +18,9 @@ internal class RepositoryHandler
private readonly Guid _clientId;
private readonly ClientDiagnostics _clientDiagnostics;
private readonly Uri _repositoryUri;
- private readonly ModelsRepoClientOptions _clientOptions;
+ private readonly ModelsRepositoryClientOptions _clientOptions;
- public RepositoryHandler(Uri repositoryUri, ClientDiagnostics clientDiagnostics, ModelsRepoClientOptions options)
+ public RepositoryHandler(Uri repositoryUri, ClientDiagnostics clientDiagnostics, ModelsRepositoryClientOptions options)
{
Argument.AssertNotNull(options, nameof(options));
@@ -33,7 +33,7 @@ public RepositoryHandler(Uri repositoryUri, ClientDiagnostics clientDiagnostics,
_repositoryUri = repositoryUri;
- ModelsRepoEventSource.Instance.InitFetcher(_clientId, repositoryUri.Scheme);
+ ModelsRepositoryEventSource.Instance.InitFetcher(_clientId, repositoryUri.Scheme);
}
public async Task> ProcessAsync(string dtmi, CancellationToken cancellationToken)
@@ -68,11 +68,11 @@ private async Task> ProcessAsync(IEnumerable
string targetDtmi = toProcessModels.Dequeue();
if (processedModels.ContainsKey(targetDtmi))
{
- ModelsRepoEventSource.Instance.SkippingPreprocessedDtmi(targetDtmi);
+ ModelsRepositoryEventSource.Instance.SkippingPreprocessedDtmi(targetDtmi);
continue;
}
- ModelsRepoEventSource.Instance.ProcessingDtmi(targetDtmi);
+ ModelsRepositoryEventSource.Instance.ProcessingDtmi(targetDtmi);
FetchResult result = async
? await FetchAsync(targetDtmi, cancellationToken).ConfigureAwait(false)
@@ -101,7 +101,7 @@ private async Task> ProcessAsync(IEnumerable
if (dependencies.Count > 0)
{
- ModelsRepoEventSource.Instance.DiscoveredDependencies(string.Join("\", \"", dependencies));
+ ModelsRepositoryEventSource.Instance.DiscoveredDependencies(string.Join("\", \"", dependencies));
}
foreach (string dep in dependencies)
@@ -113,7 +113,7 @@ private async Task> ProcessAsync(IEnumerable
string parsedDtmi = metadata.Id;
if (!parsedDtmi.Equals(targetDtmi, StringComparison.Ordinal))
{
- ModelsRepoEventSource.Instance.IncorrectDtmiCasing(targetDtmi, parsedDtmi);
+ ModelsRepositoryEventSource.Instance.IncorrectDtmiCasing(targetDtmi, parsedDtmi);
string formatErrorMsg =
$"{string.Format(CultureInfo.CurrentCulture, ServiceStrings.GenericResolverError, targetDtmi)} " +
string.Format(CultureInfo.CurrentCulture, ServiceStrings.IncorrectDtmiCasing, targetDtmi, parsedDtmi);
@@ -144,7 +144,7 @@ private static Queue PrepareWork(IEnumerable dtmis)
{
if (!DtmiConventions.IsDtmi(dtmi))
{
- ModelsRepoEventSource.Instance.InvalidDtmiInput(dtmi);
+ ModelsRepositoryEventSource.Instance.InvalidDtmiInput(dtmi);
string invalidArgMsg =
$"{string.Format(CultureInfo.CurrentCulture, ServiceStrings.GenericResolverError, dtmi)} " +
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ClientTests.cs b/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ClientTests.cs
index de5c4f9a213c1..2d3179d56aec0 100644
--- a/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ClientTests.cs
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ClientTests.cs
@@ -8,7 +8,7 @@
namespace Azure.Iot.ModelsRepository.Tests
{
- public class ClientTests : ModelsRepoTestBase
+ public class ClientTests : ModelsRepositoryTestBase
{
[Test]
public void CtorOverloads()
@@ -16,29 +16,26 @@ public void CtorOverloads()
string remoteUriStr = "https://dtmi.com";
Uri remoteUri = new Uri(remoteUriStr);
- ModelsRepoClientOptions options = new ModelsRepoClientOptions();
+ ModelsRepositoryClientOptions options = new ModelsRepositoryClientOptions();
- Assert.AreEqual(new Uri(ModelsRepoClient.DefaultModelsRepository), new ModelsRepoClient().RepositoryUri);
- Assert.AreEqual($"{ModelsRepoClient.DefaultModelsRepository}/", new ModelsRepoClient().RepositoryUri.AbsoluteUri);
- Assert.AreEqual(new Uri(ModelsRepoClient.DefaultModelsRepository), new ModelsRepoClient(options).RepositoryUri);
+ Assert.AreEqual(ModelsRepositoryClient.DefaultModelsRepository, new ModelsRepositoryClient().RepositoryUri);
+ Assert.AreEqual(ModelsRepositoryClient.DefaultModelsRepository, new ModelsRepositoryClient().RepositoryUri);
+ Assert.AreEqual(ModelsRepositoryClient.DefaultModelsRepository, new ModelsRepositoryClient(options).RepositoryUri);
- Assert.AreEqual(remoteUri, new ModelsRepoClient(remoteUri).RepositoryUri);
- Assert.AreEqual(remoteUri, new ModelsRepoClient(remoteUri, options).RepositoryUri);
-
- Assert.AreEqual(remoteUri, new ModelsRepoClient(remoteUriStr).RepositoryUri);
- Assert.AreEqual(remoteUri, new ModelsRepoClient(remoteUriStr, options).RepositoryUri);
+ Assert.AreEqual(remoteUri, new ModelsRepositoryClient(remoteUri).RepositoryUri);
+ Assert.AreEqual(remoteUri, new ModelsRepositoryClient(remoteUri, options).RepositoryUri);
string localUriStr = TestLocalModelRepository;
Uri localUri = new Uri(localUriStr);
- Assert.AreEqual(localUri, new ModelsRepoClient(localUri).RepositoryUri);
+ Assert.AreEqual(localUri, new ModelsRepositoryClient(localUri).RepositoryUri);
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
localUriStr = localUriStr.Replace("\\", "/");
}
- Assert.AreEqual(localUriStr, new ModelsRepoClient(localUri).RepositoryUri.AbsolutePath);
+ Assert.AreEqual(localUriStr, new ModelsRepositoryClient(localUri).RepositoryUri.AbsolutePath);
}
[TestCase("dtmi:com:example:Thermostat;1", true)]
@@ -50,35 +47,13 @@ public void CtorOverloads()
[TestCase(null, false)]
public void ClientIsValidDtmi(string dtmi, bool expected)
{
- Assert.AreEqual(expected, ModelsRepoClient.IsValidDtmi(dtmi));
- }
-
- [Test]
- public void ClientOptions()
- {
- DependencyResolutionOption defaultResolutionOption = DependencyResolutionOption.Enabled;
-
- ModelsRepoClientOptions customOptions =
- new ModelsRepoClientOptions(resolutionOption: DependencyResolutionOption.TryFromExpanded);
-
- int maxRetries = 10;
- customOptions.Retry.MaxRetries = maxRetries;
-
- string repositoryUriString = "https://localhost/myregistry/";
- Uri repositoryUri = new Uri(repositoryUriString);
-
- ModelsRepoClient defaultClient = new ModelsRepoClient(repositoryUri);
- Assert.AreEqual(defaultResolutionOption, defaultClient.ClientOptions.DependencyResolution);
-
- ModelsRepoClient customClient = new ModelsRepoClient(repositoryUriString, customOptions);
- Assert.AreEqual(DependencyResolutionOption.TryFromExpanded, customClient.ClientOptions.DependencyResolution);
- Assert.AreEqual(maxRetries, customClient.ClientOptions.Retry.MaxRetries);
+ Assert.AreEqual(expected, ModelsRepositoryClient.IsValidDtmi(dtmi));
}
[Test]
public void EvaluateEventSourceKPIs()
{
- Type eventSourceType = typeof(ModelsRepoEventSource);
+ Type eventSourceType = typeof(ModelsRepositoryEventSource);
Assert.NotNull(eventSourceType);
Assert.AreEqual(ModelRepositoryConstants.ModelRepositoryEventSourceName, EventSource.GetName(eventSourceType));
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/DtmiConversionTests.cs b/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/DtmiConversionTests.cs
index e39cc27d13356..f8c0c4dff08a7 100644
--- a/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/DtmiConversionTests.cs
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/DtmiConversionTests.cs
@@ -7,7 +7,7 @@
namespace Azure.Iot.ModelsRepository.Tests
{
- public class DtmiConversionTests : ModelsRepoTestBase
+ public class DtmiConversionTests : ModelsRepositoryTestBase
{
[TestCase("dtmi:com:Example:Model;1", "dtmi/com/example/model-1.json")]
[TestCase("dtmi:com:example:Model;1", "dtmi/com/example/model-1.json")]
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelQueryTests.cs b/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelQueryTests.cs
index cda87c7ceebc6..06ba7ffc08e54 100644
--- a/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelQueryTests.cs
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelQueryTests.cs
@@ -8,7 +8,7 @@
namespace Azure.Iot.ModelsRepository.Tests
{
- public class ModelQueryTests : ModelsRepoTestBase
+ public class ModelQueryTests : ModelsRepositoryTestBase
{
private readonly string _modelTemplate = @"{{
{0}
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelsRepoRecordedTestBase.cs b/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelsRepositoryRecordedTestBase.cs
similarity index 57%
rename from sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelsRepoRecordedTestBase.cs
rename to sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelsRepositoryRecordedTestBase.cs
index 9cc24adbfcdac..d410525056121 100644
--- a/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelsRepoRecordedTestBase.cs
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelsRepositoryRecordedTestBase.cs
@@ -8,7 +8,7 @@
namespace Azure.Iot.ModelsRepository.Tests
{
- public class ModelsRepoRecordedTestBase : RecordedTestBase
+ public class ModelsRepositoryRecordedTestBase : RecordedTestBase
{
protected const string TestModeEnvVariable = "AZURE_TEST_MODE";
@@ -16,7 +16,7 @@ public class ModelsRepoRecordedTestBase : RecordedTestBase
/// This class will initialize all the settings and create and instance of the ModelsRepoClient.
///
- public abstract class ModelsRepoTestBase
+ public abstract class ModelsRepositoryTestBase
{
- public ModelsRepoTestBase()
+ public ModelsRepositoryTestBase()
{
}
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelsRepoTestEnvironment.cs b/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelsRepositoryTestEnvironment.cs
similarity index 74%
rename from sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelsRepoTestEnvironment.cs
rename to sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelsRepositoryTestEnvironment.cs
index d1f757776f77c..747bf03756691 100644
--- a/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelsRepoTestEnvironment.cs
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ModelsRepositoryTestEnvironment.cs
@@ -5,7 +5,7 @@
namespace Azure.Iot.ModelsRepository.Tests
{
- public class ModelsRepoTestEnvironment : TestEnvironment
+ public class ModelsRepositoryTestEnvironment : TestEnvironment
{
}
}
diff --git a/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ResolveIntegrationTests.cs b/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ResolveIntegrationTests.cs
index 82658fb19d385..bb937b3e4d003 100644
--- a/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ResolveIntegrationTests.cs
+++ b/sdk/modelsrepository/Azure.Iot.ModelsRepository/tests/ResolveIntegrationTests.cs
@@ -9,19 +9,19 @@
namespace Azure.Iot.ModelsRepository.Tests
{
- public class ResolveIntegrationTests : ModelsRepoRecordedTestBase
+ public class ResolveIntegrationTests : ModelsRepositoryRecordedTestBase
{
public ResolveIntegrationTests(bool isAsync) : base(isAsync)
{
}
- [TestCase(ModelsRepoTestBase.ClientType.Local)]
- [TestCase(ModelsRepoTestBase.ClientType.Remote)]
- public void ResolveWithWrongCasingThrowsException(ModelsRepoTestBase.ClientType clientType)
+ [TestCase(ModelsRepositoryTestBase.ClientType.Local)]
+ [TestCase(ModelsRepositoryTestBase.ClientType.Remote)]
+ public void ResolveWithWrongCasingThrowsException(ModelsRepositoryTestBase.ClientType clientType)
{
const string dtmi = "dtmi:com:example:thermostat;1";
- ModelsRepoClient client = GetClient(clientType);
+ ModelsRepositoryClient client = GetClient(clientType);
string expectedExMsg =
string.Format(ServiceStrings.GenericResolverError, "dtmi:com:example:thermostat;1") +
" " +
@@ -36,19 +36,19 @@ public void ResolveWithWrongCasingThrowsException(ModelsRepoTestBase.ClientType
[TestCase("com:example:Thermostat;1")]
public void ResolveInvalidDtmiFormatThrowsException(string dtmi)
{
- ModelsRepoClient client = GetClient(ModelsRepoTestBase.ClientType.Local);
+ ModelsRepositoryClient client = GetClient(ModelsRepositoryTestBase.ClientType.Local);
string expectedExMsg = $"{string.Format(ServiceStrings.GenericResolverError, dtmi)} {string.Format(ServiceStrings.InvalidDtmiFormat, dtmi)}";
RequestFailedException re = Assert.ThrowsAsync(async () => await client.ResolveAsync(dtmi));
Assert.AreEqual(re.Message, expectedExMsg);
}
- [TestCase(ModelsRepoTestBase.ClientType.Local)]
- [TestCase(ModelsRepoTestBase.ClientType.Remote)]
- public void ResolveNoneExistentDtmiFileThrowsException(ModelsRepoTestBase.ClientType clientType)
+ [TestCase(ModelsRepositoryTestBase.ClientType.Local)]
+ [TestCase(ModelsRepositoryTestBase.ClientType.Remote)]
+ public void ResolveNoneExistentDtmiFileThrowsException(ModelsRepositoryTestBase.ClientType clientType)
{
const string dtmi = "dtmi:com:example:thermojax;999";
- ModelsRepoClient client = GetClient(clientType);
+ ModelsRepositoryClient client = GetClient(clientType);
RequestFailedException re = Assert.ThrowsAsync(async () => await client.ResolveAsync(dtmi));
Assert.True(re.Message.StartsWith($"Unable to resolve \"{dtmi}\""));
}
@@ -58,48 +58,48 @@ public void ResolveInvalidDtmiDepsThrowsException()
const string dtmi = "dtmi:com:example:invalidmodel;1";
const string invalidDep = "dtmi:azure:fakeDeviceManagement:FakeDeviceInformation;2";
- ModelsRepoClient client = GetClient(ModelsRepoTestBase.ClientType.Local);
+ ModelsRepositoryClient client = GetClient(ModelsRepositoryTestBase.ClientType.Local);
RequestFailedException resolverException = Assert.ThrowsAsync(async () => await client.ResolveAsync(dtmi));
Assert.True(resolverException.Message.StartsWith($"Unable to resolve \"{invalidDep}\""));
}
- [TestCase(ModelsRepoTestBase.ClientType.Local)]
- [TestCase(ModelsRepoTestBase.ClientType.Remote)]
- public async Task ResolveSingleModelNoDeps(ModelsRepoTestBase.ClientType clientType)
+ [TestCase(ModelsRepositoryTestBase.ClientType.Local)]
+ [TestCase(ModelsRepositoryTestBase.ClientType.Remote)]
+ public async Task ResolveSingleModelNoDeps(ModelsRepositoryTestBase.ClientType clientType)
{
const string dtmi = "dtmi:com:example:Thermostat;1";
- ModelsRepoClient client = GetClient(clientType);
+ ModelsRepositoryClient client = GetClient(clientType);
IDictionary result = await client.ResolveAsync(dtmi);
Assert.True(result.Keys.Count == 1);
Assert.True(result.ContainsKey(dtmi));
- Assert.True(ModelsRepoTestBase.ParseRootDtmiFromJson(result[dtmi]) == dtmi);
+ Assert.True(ModelsRepositoryTestBase.ParseRootDtmiFromJson(result[dtmi]) == dtmi);
}
- [TestCase(ModelsRepoTestBase.ClientType.Local)]
- [TestCase(ModelsRepoTestBase.ClientType.Remote)]
- public async Task ResolveMultipleModelsNoDeps(ModelsRepoTestBase.ClientType clientType)
+ [TestCase(ModelsRepositoryTestBase.ClientType.Local)]
+ [TestCase(ModelsRepositoryTestBase.ClientType.Remote)]
+ public async Task ResolveMultipleModelsNoDeps(ModelsRepositoryTestBase.ClientType clientType)
{
const string dtmi1 = "dtmi:com:example:Thermostat;1";
const string dtmi2 = "dtmi:azure:DeviceManagement:DeviceInformation;1";
- ModelsRepoClient client = GetClient(clientType);
+ ModelsRepositoryClient client = GetClient(clientType);
IDictionary result = await client.ResolveAsync(new string[] { dtmi1, dtmi2 });
Assert.True(result.Keys.Count == 2);
Assert.True(result.ContainsKey(dtmi1));
Assert.True(result.ContainsKey(dtmi2));
- Assert.True(ModelsRepoTestBase.ParseRootDtmiFromJson(result[dtmi1]) == dtmi1);
- Assert.True(ModelsRepoTestBase.ParseRootDtmiFromJson(result[dtmi2]) == dtmi2);
+ Assert.True(ModelsRepositoryTestBase.ParseRootDtmiFromJson(result[dtmi1]) == dtmi1);
+ Assert.True(ModelsRepositoryTestBase.ParseRootDtmiFromJson(result[dtmi2]) == dtmi2);
}
- [TestCase(ModelsRepoTestBase.ClientType.Local)]
- [TestCase(ModelsRepoTestBase.ClientType.Remote)]
- public async Task ResolveSingleModelWithDeps(ModelsRepoTestBase.ClientType clientType)
+ [TestCase(ModelsRepositoryTestBase.ClientType.Local)]
+ [TestCase(ModelsRepositoryTestBase.ClientType.Remote)]
+ public async Task ResolveSingleModelWithDeps(ModelsRepositoryTestBase.ClientType clientType)
{
const string dtmi = "dtmi:com:example:TemperatureController;1";
const string expectedDeps = "dtmi:com:example:Thermostat;1,dtmi:azure:DeviceManagement:DeviceInformation;1";
- ModelsRepoClient client = GetClient(clientType);
+ ModelsRepositoryClient client = GetClient(clientType);
IDictionary result = await client.ResolveAsync(dtmi);
var expectedDtmis = $"{dtmi},{expectedDeps}".Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
@@ -107,7 +107,7 @@ public async Task ResolveSingleModelWithDeps(ModelsRepoTestBase.ClientType clien
foreach (var id in expectedDtmis)
{
Assert.True(result.ContainsKey(id));
- Assert.True(ModelsRepoTestBase.ParseRootDtmiFromJson(result[id]) == id);
+ Assert.True(ModelsRepositoryTestBase.ParseRootDtmiFromJson(result[id]) == id);
}
// TODO: Evaluate using Azure.Core.TestFramework in future iteration.
@@ -138,7 +138,7 @@ public async Task ResolveMultipleModelsWithDeps()
"dtmi:azure:DeviceManagement:DeviceInformation;2," +
"dtmi:com:example:Camera;3";
- ModelsRepoClient client = GetClient(ModelsRepoTestBase.ClientType.Local);
+ ModelsRepositoryClient client = GetClient(ModelsRepositoryTestBase.ClientType.Local);
IDictionary result = await client.ResolveAsync(new[] { dtmi1, dtmi2 });
var expectedDtmis = $"{dtmi1},{dtmi2},{expectedDeps}".Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
@@ -146,7 +146,7 @@ public async Task ResolveMultipleModelsWithDeps()
foreach (var id in expectedDtmis)
{
Assert.True(result.ContainsKey(id));
- Assert.True(ModelsRepoTestBase.ParseRootDtmiFromJson(result[id]) == id);
+ Assert.True(ModelsRepositoryTestBase.ParseRootDtmiFromJson(result[id]) == id);
}
}
@@ -155,7 +155,7 @@ public async Task ResolveMultipleModelsWithDepsFromExtends()
const string dtmi1 = "dtmi:com:example:TemperatureController;1";
const string dtmi2 = "dtmi:com:example:ConferenceRoom;1";
const string expectedDeps = "dtmi:com:example:Thermostat;1,dtmi:azure:DeviceManagement:DeviceInformation;1,dtmi:com:example:Room;1";
- ModelsRepoClient client = GetClient(ModelsRepoTestBase.ClientType.Local);
+ ModelsRepositoryClient client = GetClient(ModelsRepositoryTestBase.ClientType.Local);
IDictionary result = await client.ResolveAsync(new[] { dtmi1, dtmi2 });
var expectedDtmis = $"{dtmi1},{dtmi2},{expectedDeps}".Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
@@ -163,7 +163,7 @@ public async Task ResolveMultipleModelsWithDepsFromExtends()
foreach (var id in expectedDtmis)
{
Assert.True(result.ContainsKey(id));
- Assert.True(ModelsRepoTestBase.ParseRootDtmiFromJson(result[id]) == id);
+ Assert.True(ModelsRepositoryTestBase.ParseRootDtmiFromJson(result[id]) == id);
}
}
@@ -176,7 +176,7 @@ public async Task ResolveMultipleModelsWithDepsFromExtendsVariant()
"dtmi:com:example:Room;1," +
"dtmi:com:example:Freezer;1";
- ModelsRepoClient client = GetClient(ModelsRepoTestBase.ClientType.Local);
+ ModelsRepositoryClient client = GetClient(ModelsRepositoryTestBase.ClientType.Local);
IDictionary result = await client.ResolveAsync(new[] { dtmi1, dtmi2 });
var expectedDtmis = $"{dtmi1},{dtmi2},{expectedDeps}".Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
@@ -184,19 +184,19 @@ public async Task ResolveMultipleModelsWithDepsFromExtendsVariant()
foreach (var id in expectedDtmis)
{
Assert.True(result.ContainsKey(id));
- Assert.True(ModelsRepoTestBase.ParseRootDtmiFromJson(result[id]) == id);
+ Assert.True(ModelsRepositoryTestBase.ParseRootDtmiFromJson(result[id]) == id);
}
}
public async Task ResolveSingleModelWithDepsFromExtendsInline()
{
const string dtmi = "dtmi:com:example:base;1";
- ModelsRepoClient client = GetClient(ModelsRepoTestBase.ClientType.Local);
+ ModelsRepositoryClient client = GetClient(ModelsRepositoryTestBase.ClientType.Local);
IDictionary result = await client.ResolveAsync(dtmi);
Assert.True(result.Keys.Count == 1);
Assert.True(result.ContainsKey(dtmi));
- Assert.True(ModelsRepoTestBase.ParseRootDtmiFromJson(result[dtmi]) == dtmi);
+ Assert.True(ModelsRepositoryTestBase.ParseRootDtmiFromJson(result[dtmi]) == dtmi);
}
public async Task ResolveSingleModelWithDepsFromExtendsInlineVariant()
@@ -205,7 +205,7 @@ public async Task ResolveSingleModelWithDepsFromExtendsInlineVariant()
const string expected = "dtmi:com:example:Freezer;1," +
"dtmi:com:example:Thermostat;1";
- ModelsRepoClient client = GetClient(ModelsRepoTestBase.ClientType.Local);
+ ModelsRepositoryClient client = GetClient(ModelsRepositoryTestBase.ClientType.Local);
IDictionary result = await client.ResolveAsync(dtmi);
var expectedDtmis = $"{dtmi},{expected}".Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
@@ -213,7 +213,7 @@ public async Task ResolveSingleModelWithDepsFromExtendsInlineVariant()
foreach (var id in expectedDtmis)
{
Assert.True(result.ContainsKey(id));
- Assert.True(ModelsRepoTestBase.ParseRootDtmiFromJson(result[id]) == id);
+ Assert.True(ModelsRepositoryTestBase.ParseRootDtmiFromJson(result[id]) == id);
}
}
@@ -222,39 +222,39 @@ public async Task ResolveEnsuresNoDupes()
const string dtmiDupe1 = "dtmi:azure:DeviceManagement:DeviceInformation;1";
const string dtmiDupe2 = "dtmi:azure:DeviceManagement:DeviceInformation;1";
- ModelsRepoClient client = GetClient(ModelsRepoTestBase.ClientType.Local);
+ ModelsRepositoryClient client = GetClient(ModelsRepositoryTestBase.ClientType.Local);
IDictionary result = await client.ResolveAsync(new[] { dtmiDupe1, dtmiDupe2 });
Assert.True(result.Keys.Count == 1);
- Assert.True(ModelsRepoTestBase.ParseRootDtmiFromJson(result[dtmiDupe1]) == dtmiDupe1);
+ Assert.True(ModelsRepositoryTestBase.ParseRootDtmiFromJson(result[dtmiDupe1]) == dtmiDupe1);
}
- [TestCase(ModelsRepoTestBase.ClientType.Local)]
- [TestCase(ModelsRepoTestBase.ClientType.Remote)]
- public async Task ResolveSingleModelWithDepsDisableDependencyResolution(ModelsRepoTestBase.ClientType clientType)
+ [TestCase(ModelsRepositoryTestBase.ClientType.Local)]
+ [TestCase(ModelsRepositoryTestBase.ClientType.Remote)]
+ public async Task ResolveSingleModelWithDepsDisableDependencyResolution(ModelsRepositoryTestBase.ClientType clientType)
{
const string dtmi = "dtmi:com:example:Thermostat;1";
- ModelsRepoClientOptions options = new ModelsRepoClientOptions(resolutionOption: DependencyResolutionOption.Disabled);
- ModelsRepoClient client = GetClient(clientType, options);
+ ModelsRepositoryClientOptions options = new ModelsRepositoryClientOptions(resolutionOption: DependencyResolutionOption.Disabled);
+ ModelsRepositoryClient client = GetClient(clientType, options);
IDictionary result = await client.ResolveAsync(dtmi);
Assert.True(result.Keys.Count == 1);
Assert.True(result.ContainsKey(dtmi));
- Assert.True(ModelsRepoTestBase.ParseRootDtmiFromJson(result[dtmi]) == dtmi);
+ Assert.True(ModelsRepositoryTestBase.ParseRootDtmiFromJson(result[dtmi]) == dtmi);
}
- [TestCase(ModelsRepoTestBase.ClientType.Local)]
- [TestCase(ModelsRepoTestBase.ClientType.Remote)]
- public async Task ResolveSingleModelTryFromExpanded(ModelsRepoTestBase.ClientType clientType)
+ [TestCase(ModelsRepositoryTestBase.ClientType.Local)]
+ [TestCase(ModelsRepositoryTestBase.ClientType.Remote)]
+ public async Task ResolveSingleModelTryFromExpanded(ModelsRepositoryTestBase.ClientType clientType)
{
const string dtmi = "dtmi:com:example:TemperatureController;1";
const string expectedDeps = "dtmi:com:example:Thermostat;1,dtmi:azure:DeviceManagement:DeviceInformation;1";
var expectedDtmis = $"{dtmi},{expectedDeps}".Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
- ModelsRepoClientOptions options = new ModelsRepoClientOptions(resolutionOption: DependencyResolutionOption.TryFromExpanded);
- ModelsRepoClient client = GetClient(clientType, options);
+ ModelsRepositoryClientOptions options = new ModelsRepositoryClientOptions(resolutionOption: DependencyResolutionOption.TryFromExpanded);
+ ModelsRepositoryClient client = GetClient(clientType, options);
IDictionary result = await client.ResolveAsync(dtmi);
@@ -262,7 +262,7 @@ public async Task ResolveSingleModelTryFromExpanded(ModelsRepoTestBase.ClientTyp
foreach (var id in expectedDtmis)
{
Assert.True(result.ContainsKey(id));
- Assert.True(ModelsRepoTestBase.ParseRootDtmiFromJson(result[id]) == id);
+ Assert.True(ModelsRepositoryTestBase.ParseRootDtmiFromJson(result[id]) == id);
}
// TODO: Evaluate using Azure.Core.TestFramework in future iteration.
@@ -290,8 +290,8 @@ public async Task ResolveMultipleModelsTryFromExpandedPartial()
string[] nonExpandedDtmis = dtmisNonExpanded.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
string[] totalDtmis = expandedDtmis.Concat(nonExpandedDtmis).ToArray();
- ModelsRepoClientOptions options = new ModelsRepoClientOptions(resolutionOption: DependencyResolutionOption.TryFromExpanded);
- ModelsRepoClient client = GetClient(ModelsRepoTestBase.ClientType.Local, options);
+ ModelsRepositoryClientOptions options = new ModelsRepositoryClientOptions(resolutionOption: DependencyResolutionOption.TryFromExpanded);
+ ModelsRepositoryClient client = GetClient(ModelsRepositoryTestBase.ClientType.Local, options);
// Multi-resolve dtmi:com:example:TemperatureController;1 + dtmi:com:example:ColdStorage;1
IDictionary result = await client.ResolveAsync(new[] { expandedDtmis[0], nonExpandedDtmis[0] });
@@ -300,7 +300,7 @@ public async Task ResolveMultipleModelsTryFromExpandedPartial()
foreach (string id in totalDtmis)
{
Assert.True(result.ContainsKey(id));
- Assert.True(ModelsRepoTestBase.ParseRootDtmiFromJson(result[id]) == id);
+ Assert.True(ModelsRepositoryTestBase.ParseRootDtmiFromJson(result[id]) == id);
}
// TODO: Evaluate using Azure.Core.TestFramework in future iteration.