Пример #1
0
        public void CreateWorkspace_Success()
        {
            Console.WriteLine("\nCalling CreateWorkspace()...");
            CreateWorkspace workspace = new CreateWorkspace()
            {
                Name        = _createdWorkspaceName,
                Description = _createdWorkspaceDescription,
                Language    = _createdWorkspaceLanguage
            };

            var result = conversation.CreateWorkspace(workspace);


            if (result != null)
            {
                Console.WriteLine(string.Format("Workspace Name: {0}, id: {1}, description: {2}", result.Name, result.WorkspaceId, result.Description));
                if (!string.IsNullOrEmpty(result.WorkspaceId))
                {
                    _createdWorkspaceId = result.WorkspaceId;
                }
            }
            else
            {
                Console.WriteLine("Result is null.");
            }

            Assert.IsNotNull(result);
        }
        public void CreateWorkspace()
        {
            #region worskpace

            CreateWorkspace workspace = new CreateWorkspace()
            {
                Name = "Test SDK",
                Description = "Test Conversation SDK",
                Language = "en",
                Metadata = new object() { },
                CounterExamples = new List<CreateExample>()
               {
                   new CreateExample()
                   {
                       Text = "How to increase revenue"
                   }
               },
                DialogNodes = new List<CreateDialogNode>()
               {
                   new CreateDialogNode()
                   {
                       DialogNode = "node_2",
                       Description = null,
                       Conditions = null,
                       Parent = "node_1",
                       PreviousSibling = null,
                       Output = new DialogNodeOutput()
                       {
                           Text = "But now... Back to business"
                       },
                       Context = null,
                       Metadata = new object() { },
                       GoTo = null
                   },
                   new CreateDialogNode()
                   {
                       DialogNode = "node_1",
                       Description = null,
                       Conditions = "revenue",
                       Parent = null,
                       PreviousSibling = null,
                       Output = new DialogNodeOutput()
                       {
                           Text = "ok.. you have been putting a few pounds lately, so I recommend you go to the Green Bowl for a salad - it has 5 star rating on yelp and I recommend the cesar salad for \\$9.75. :-)"
                       },
                       Context = null,
                       Metadata = new object() { },
                       GoTo = new DialogNodeGoTo()
                       {
                           Return = true,
                           Selector = "body",
                           DialogNode = "node_2"
                       }
                   }
               },
                Entities = new List<CreateEntity>()
               {
                   new CreateEntity()
                   {
                       Entity = "Metrics",
                       Description = null,
                       Source = null,
                       OpenList = false,
                       Type = null,
                       Values = new List<CreateValue>()
                       {
                           new CreateValue()
                           {
                               Value = "Market Share",
                               Metadata = new object() { },
                               Synonyms = new List<string>() {"closing the gap", "ground", "share"}
                           },
                           new CreateValue()
                           {
                               Value = "Profit",
                               Metadata = new object() { },
                               Synonyms = new List<string>() {"bottomline", "earnings", "gain", "margin", "margins", "net", "profit", "profits", "return", "yield"}
                           },
                           new CreateValue()
                           {
                               Value = "Revenue",
                               Metadata = new object() { },
                               Synonyms = new List<string>() {"income", "sales", "topline"}
                           }
                       }
                   }
               },
                Intents = new List<CreateIntent>()
              {
                  new CreateIntent()
                  {
                      Intent = "not_happy",
                      Description = null,
                      Examples = new List<CreateExample>()
                      {
                          new CreateExample()
                          {
                              Text = "I'm not happy with my company results"
                          }
                      }
                  }
              }
            };

            #endregion

            ConversationService service = new ConversationService(_userName, _password);
            service.Endpoint = _endpoint;

            var results = service.CreateWorkspace(workspace);
            _tempWorkspace = results.WorkspaceId;

            Assert.IsNotNull(results);
        }