Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
[ITSM] add tests
Browse files Browse the repository at this point in the history
* ServiceNowServiceTests
* TicketCreateFlowTests, TicketShowFlowTests, TicketUpdateFlowTests,
TicketCloseUtterances
* KnowledgeShowTests
  • Loading branch information
Hualiang Xie committed Oct 31, 2019
1 parent 2761615 commit 3f59b27
Show file tree
Hide file tree
Showing 34 changed files with 1,531 additions and 10 deletions.
11 changes: 11 additions & 0 deletions skills/csharp/Skills.sln
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PointOfInterestSkill.Tests"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ToDoSkill.Tests", "tests\todoskill.tests\ToDoSkill.Tests.csproj", "{5882D204-F86A-47D1-8685-BFD357E5EBF6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ITSMSkill.Tests", "tests\itsmskill.tests\ITSMSkill.Tests.csproj", "{C3304FB4-D4D5-412F-9312-1ECE4DE573DA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug - NuGet Packages|Any CPU = Debug - NuGet Packages|Any CPU
Expand Down Expand Up @@ -217,6 +219,14 @@ Global
{5882D204-F86A-47D1-8685-BFD357E5EBF6}.Documentation|Any CPU.Build.0 = Debug|Any CPU
{5882D204-F86A-47D1-8685-BFD357E5EBF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5882D204-F86A-47D1-8685-BFD357E5EBF6}.Release|Any CPU.Build.0 = Release|Any CPU
{C3304FB4-D4D5-412F-9312-1ECE4DE573DA}.Debug - NuGet Packages|Any CPU.ActiveCfg = Debug|Any CPU
{C3304FB4-D4D5-412F-9312-1ECE4DE573DA}.Debug - NuGet Packages|Any CPU.Build.0 = Debug|Any CPU
{C3304FB4-D4D5-412F-9312-1ECE4DE573DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3304FB4-D4D5-412F-9312-1ECE4DE573DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3304FB4-D4D5-412F-9312-1ECE4DE573DA}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU
{C3304FB4-D4D5-412F-9312-1ECE4DE573DA}.Documentation|Any CPU.Build.0 = Debug|Any CPU
{C3304FB4-D4D5-412F-9312-1ECE4DE573DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3304FB4-D4D5-412F-9312-1ECE4DE573DA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -242,6 +252,7 @@ Global
{D579437F-2F4A-47D3-9052-A0F2D89AA462} = {15B08548-1311-4749-8816-186C3268386E}
{60C61091-17E1-46B7-A358-190843D3AFE7} = {15B08548-1311-4749-8816-186C3268386E}
{5882D204-F86A-47D1-8685-BFD357E5EBF6} = {15B08548-1311-4749-8816-186C3268386E}
{C3304FB4-D4D5-412F-9312-1ECE4DE573DA} = {15B08548-1311-4749-8816-186C3268386E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7B849B7E-CCF5-4031-91F7-CA835433B457}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "AdaptiveCard",
"id": "TicketCard",
"id": "KnowledgeCard",
"body": [
{
"type": "Container",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "AdaptiveCard",
"id": "TicketCard",
"id": "KnowledgeCard",
"body": [
{
"type": "Container",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "AdaptiveCard",
"id": "TicketNoCloseCard",
"id": "TicketUpdateCard",
"body": [
{
"type": "Container",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "AdaptiveCard",
"id": "TicketNoCloseCard",
"id": "TicketUpdateCard",
"body": [
{
"type": "Container",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "AdaptiveCard",
"id": "TicketCard",
"id": "TicketUpdateCloseCard",
"body": [
{
"type": "Container",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "AdaptiveCard",
"id": "TicketCard",
"id": "TicketUpdateCloseCard",
"body": [
{
"type": "Container",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Ticket can be closed by {CloseReason}
- Ticket can be closed
- Close the ticket with {CloseReason}
- close [the] [ticket] {TicketNumber} ((by|with)|(because|due to)) {CloseReason}

> resolve

Expand All @@ -24,3 +25,4 @@
- i would like to resolve an issue
- i would like to resolve an incident
- Resolve the ticket with {CloseReason}
- resolve [the] [ticket] {TicketNumber} ((by|with)|(because|due to)) {CloseReason}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- i would like to add a ticket
- please add a new issue for {TicketTitle}
- please add a new ticket about {TicketTitle}
- add an urgency {UrgencyLevel} (ticket|incident|issue) (about|for|to) {TicketTitle}

> create

Expand All @@ -24,6 +25,7 @@
- create an issue for {TicketTitle}
- i would like to create for {TicketTitle}
- i'd like to create a ticket
- create an urgency {UrgencyLevel} (ticket|incident|issue) (about|for|to) {TicketTitle}

> open

Expand All @@ -33,15 +35,18 @@
- open a ticket about {TicketTitle}
- open a ticket for {TicketTitle}
- open an incident about {TicketTitle}
- open an urgency {UrgencyLevel} (ticket|incident|issue) (about|for|to) {TicketTitle}

> raise

- raise a ticket
- raise an incident
- raise an issue
- raise an issue for {TicketTitle}
- raise an urgency {UrgencyLevel} (ticket|incident|issue) (about|for|to) {TicketTitle}

> submit

- submit issue about {TicketTitle}
- submit issue for {TicketTitle}
- submit an urgency {UrgencyLevel} (ticket|incident|issue) (about|for|to) {TicketTitle}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Management : IITServiceManagement
private static readonly Dictionary<string, UrgencyLevel> StringToUrgency;
private static readonly Dictionary<TicketState, string> TicketStateToString;
private static readonly Dictionary<string, TicketState> StringToTicketState;
private readonly RestClient client;
private readonly IRestClient client;
private readonly string getUserIdResource;
private readonly string token;
private readonly int limitSize;
Expand Down Expand Up @@ -56,9 +56,9 @@ static Management()
StringToTicketState = new Dictionary<string, TicketState>(TicketStateToString.Select(pair => KeyValuePair.Create(pair.Value, pair.Key)));
}

public Management(string url, string token, int limitSize, string getUserIdResource)
public Management(string url, string token, int limitSize, string getUserIdResource, IRestClient restClient = null)
{
this.client = new RestClient($"{url}/api/");
this.client = restClient ?? new RestClient($"{url}/api/");
this.getUserIdResource = getUserIdResource;
this.token = token;
this.limitSize = limitSize;
Expand Down Expand Up @@ -359,7 +359,7 @@ private Ticket ConvertTicket(TicketResponse ticketResponse)
{
if (!string.IsNullOrEmpty(ticketResponse.close_notes))
{
ticket.ResolvedReason = $"{ticketResponse.close_code}:\n{ticketResponse.close_notes}";
ticket.ResolvedReason = $"{ticketResponse.close_code}:\r\n{ticketResponse.close_notes}";
}
else
{
Expand Down
62 changes: 62 additions & 0 deletions skills/csharp/tests/itsmskill.tests/API/Fakes/MockData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using ITSMSkill.Models;

namespace ITSMSkill.Tests.API.Fakes
{
public static class MockData
{
public const string ServiceNowProvider = "ServiceNow";

public const string ServiceNowUrl = "MockServiceNowUrl";

public const string Token = "MockToken";

public const int LimitSize = 1;

public const string ServiceNowGetUserId = "MockServiceNowGetUserId";

public const int TicketCount = 1;

public const string CreateTicketTitle = "MockCreateTicketTitle";

public const string CreateTicketDescription = "MockCreateTicketDescription";

public const string CreateTicketUrgency = "3";

public const UrgencyLevel CreateTicketUrgencyLevel = UrgencyLevel.Low;

public const string CreateTicketState = "1";

public const TicketState CreateTicketTicketState = TicketState.New;

public const string CreateTicketOpenedTime = "2016-12-12 12:12:12";

public const string CreateTicketNumber = "INC0000001";

public const string CreateTicketId = "MockCreateTicketId";

public const string CloseTicketNumber = "INC0000002";

public const string CloseTicketId = "MockCloseTicketId";

public const string CloseTicketReason = "MockCloseTicketReason";

public const string CloseTicketState = "7";

public const string CloseTicketCloseCode = "Closed/Resolved by Caller";

public const string KnowledgeTitle = "MockKnowledgeTitle";

public const string KnowledgeUpdatedTime = "2016-12-12 12:12:12";

public const string KnowledgeNumber = "MockKnowledgeNumber";

public const string KnowledgeContent = "MockKnowledgeContent";

public const int KnowledgeCount = 1;

public static string KnowledgeUrl { get => $"{ServiceNowUrl}/kb_view.do?sysparm_article={KnowledgeNumber}"; }
}
}
Loading

0 comments on commit 3f59b27

Please sign in to comment.