예제 #1
0
        public void UpdatePattern()
        {
            UseClientFor(async client =>
            {
                var version = "0.1";
                var prebuiltEntitiesToAdd = new string[]
                {
                    "datetimeV2"
                };
                var prebuiltEntitiesAdded = await client.Model.AddPrebuiltAsync(GlobalAppId, version, prebuiltEntitiesToAdd);
                var pattern = new PatternRuleCreateObject {
                    Intent = "None", Pattern = "This is a {datetimeV2}"
                };
                var updatedPattern = new PatternRuleUpdateObject {
                    Intent = "None", Pattern = "This [is] a {datetimeV2}"
                };

                var addResult    = await client.Pattern.AddPatternAsync(GlobalAppId, "0.1", pattern);
                var updateResult = await client.Pattern.UpdatePatternAsync(GlobalAppId, "0.1", addResult.Id.Value, updatedPattern);
                await client.Pattern.DeletePatternAsync(GlobalAppId, "0.1", addResult.Id.Value);
                foreach (var added in prebuiltEntitiesAdded)
                {
                    await client.Model.DeletePrebuiltAsync(GlobalAppId, version, added.Id);
                }

                Assert.NotNull(updateResult);
                Assert.NotNull(updateResult.Id);
                Assert.Equal("None", updateResult.Intent);
                Assert.Equal(addResult.Id, updateResult.Id);
                Assert.NotEqual(Guid.Empty, updateResult.Id);
                Assert.Equal("this [is] a {datetimeV2}", updateResult.Pattern);
            });
        }
예제 #2
0
        public void DeletePattern()
        {
            UseClientFor(async client =>
            {
                var version = "0.1";
                var prebuiltEntitiesToAdd = new string[]
                {
                    "datetimeV2"
                };
                var prebuiltEntitiesAdded = await client.Model.AddPrebuiltAsync(GlobalAppId, version, prebuiltEntitiesToAdd);
                var pattern = new PatternRuleCreateObject {
                    Intent = "None", Pattern = "This is a {datetimeV2}"
                };
                var result = await client.Pattern.AddPatternAsync(GlobalAppId, "0.1", pattern);
                await client.Pattern.DeletePatternAsync(GlobalAppId, "0.1", result.Id.Value);
                var existingPatterns = await client.Pattern.ListPatternsAsync(GlobalAppId, "0.1");
                foreach (var added in prebuiltEntitiesAdded)
                {
                    await client.Model.DeletePrebuiltAsync(GlobalAppId, version, added.Id);
                }

                Assert.Null(existingPatterns.FirstOrDefault(p => p.Id == result.Id));
            });
        }
 /// <summary>
 /// Adds a pattern to a version of the application.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='appId'>
 /// The application ID.
 /// </param>
 /// <param name='versionId'>
 /// The version ID.
 /// </param>
 /// <param name='pattern'>
 /// The input pattern.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <PatternRuleInfo> AddPatternAsync(this IPattern operations, System.Guid appId, string versionId, PatternRuleCreateObject pattern, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.AddPatternWithHttpMessagesAsync(appId, versionId, pattern, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }