public void ResolveNoneExistentDtmiFileThrowsException(string dtmi, TestHelpers.ClientType clientType)
        {
            ResolverClient    client = TestHelpers.GetTestClient(clientType);
            ResolverException re     = Assert.ThrowsAsync <ResolverException>(async() => await client.ResolveAsync(dtmi));

            Assert.True(re.Message.StartsWith($"Unable to resolve \"{dtmi}\""));
        }
        public void ResolveInvalidDtmiDepsThrowsException(string dtmi, string invalidDep)
        {
            ResolverClient    client = TestHelpers.GetTestClient(TestHelpers.ClientType.Local);
            ResolverException re     = Assert.ThrowsAsync <ResolverException>(async() => await client.ResolveAsync(dtmi));

            Assert.True(re.Message.StartsWith($"Unable to resolve \"{invalidDep}\""));
        }
        public void ResolveInvalidDtmiFormatThrowsException(string dtmi)
        {
            string            expectedExMsg = $"{StandardStrings.GenericResolverError(dtmi)}{StandardStrings.InvalidDtmiFormat(dtmi)}";
            ResolverException re            = Assert.ThrowsAsync <ResolverException>(async() => await _localClient.ResolveAsync(dtmi));

            Assert.AreEqual(re.Message, expectedExMsg);
        }
        public void ResolveInvalidDtmiFormatThrowsException(string dtmi)
        {
            ResolverClient    client        = TestHelpers.GetTestClient(TestHelpers.ClientType.Local);
            string            expectedExMsg = $"{string.Format(StandardStrings.GenericResolverError, dtmi)}{string.Format(StandardStrings.InvalidDtmiFormat, dtmi)}";
            ResolverException re            = Assert.ThrowsAsync <ResolverException>(async() => await client.ResolveAsync(dtmi));

            Assert.AreEqual(re.Message, expectedExMsg);
        }
        public void ResolveWithWrongCasingThrowsException(string dtmi)
        {
            string expectedExMsg =
                $"{StandardStrings.GenericResolverError("dtmi:com:example:thermostat;1")}" +
                $"{StandardStrings.IncorrectDtmiCasing("dtmi:com:example:thermostat;1", "dtmi:com:example:Thermostat;1")}";

            ResolverException re = Assert.ThrowsAsync <ResolverException>(async() => await _localClient.ResolveAsync(dtmi));

            Assert.AreEqual(re.Message, expectedExMsg);
        }
        public void ResolveWithWrongCasingThrowsException(string dtmi, TestHelpers.ClientType clientType)
        {
            ResolverClient client        = TestHelpers.GetTestClient(clientType);
            string         expectedExMsg =
                string.Format(StandardStrings.GenericResolverError, "dtmi:com:example:thermostat;1") +
                string.Format(StandardStrings.IncorrectDtmiCasing, "dtmi:com:example:thermostat;1", "dtmi:com:example:Thermostat;1");

            ResolverException re = Assert.ThrowsAsync <ResolverException>(async() => await client.ResolveAsync(dtmi));

            Assert.AreEqual(re.Message, expectedExMsg);
        }
コード例 #7
0
        public void ParserValidationResolveFromLocalRepoErrorOnParserCallbackDtmiCasing()
        {
            ModelParser parser           = new ModelParser();
            string      TestRegistryPath = TestHelpers.TestLocalModelRepository;

            // This model references another model with invalid casing.
            string modelPath = $"{TestRegistryPath}/dtmi/company/demodevice-1.json";

            // Shows how to quickly integrate the resolver client with the parser.
            ResolverClient client = new ResolverClient(TestRegistryPath);

            parser.DtmiResolver = client.ParserDtmiResolver;

            // Parser will throw on validation errors

            ResolverException e =
                Assert.ThrowsAsync <ResolverException>(async() => await parser.ParseAsync(new string[] { File.ReadAllText(modelPath) }));

            Assert.AreEqual(e.Message,
                            $"{StandardStrings.GenericResolverError("dtmi:azure:deviceManagement:DeviceInformation;1")}" +
                            $"{StandardStrings.IncorrectDtmiCasing("dtmi:azure:deviceManagement:DeviceInformation;1","dtmi:azure:DeviceManagement:DeviceInformation;1")}");
        }