Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions PVATestFramework/PVATestFramework/Helpers/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public static class RoleTypes
public const int Bot = 0;
}

public static class Content
{
public const string BasicCard = "application/vnd.microsoft.card.hero";
}

public static class Constants
{
public const string DataverseTokenUri = "https://login.microsoftonline.com/{TenantId}/oauth2/v2.0/token";
Expand Down
22 changes: 21 additions & 1 deletion PVATestFramework/PVATestFramework/Helpers/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,23 @@ public bool ConvertChatFileToJSON(string path, string outputFile)
}
};
}
else if (line.StartsWith("attachment:"))
{
var attachmentRegex = new Regex(Regex.Escape("attachment:"));
var attachmentTitle = attachmentRegex.Replace(line, string.Empty, 1).Trim();
if (string.IsNullOrEmpty(attachmentTitle)){
throw new ArgumentException("The attachment title is null or empty.");
}
else {
var lastActivityList = activityList.Last();
lastActivityList.Attachments = [new Attachment(Helpers.Content.BasicCard, new BasicCardContent
{
Title = attachmentTitle,
Images = new List<string>(),
Buttons = new List<string>()
})];
}
}
else
{
throw new Exception("The input file format is not valid.");
Expand Down Expand Up @@ -456,7 +473,6 @@ private async Task<bool> ExecuteTranscriptAsync(DirectLineOptions options, Activ
logger.ForegroundColor($"Received: {receivedActivity.Text}", LoggerExtensions.LogLevel.Error, LoggerExtensions.Yellow);
logger.ForegroundColor($"Line number: {activity.LineNumber}", LoggerExtensions.LogLevel.Error, LoggerExtensions.Yellow);
}

if (activity.Attachments != null && activity.Attachments.Count > 0)
{
var expectedAttachments = activity.Attachments.Select(a => JsonConvert.SerializeObject(a.Content)).ToList();
Expand Down Expand Up @@ -617,9 +633,11 @@ private bool AssertActivity(Models.Activities.Activity expectedActivity, Activit
// This is a simple text to compare
return false;
}
logger.Information($"Testing");
}
else if (expectedActivity.Attachments != null && expectedActivity.Attachments.Count == receivedActivity.Attachments.Count)
{
logger.Information($"It entereed here");
// This is an adaptive card, so the structure comparison will be executed
var expectedAttachments = expectedActivity.Attachments.Select(a => JsonConvert.SerializeObject(a.Content)).ToList();
var receivedAttachments = receivedActivity.Attachments.Select(a => JsonConvert.SerializeObject(a.Content)).ToList();
Expand All @@ -629,6 +647,8 @@ private bool AssertActivity(Models.Activities.Activity expectedActivity, Activit
{
var expectedCard = AdaptiveCard.GetCardWithoutValues(expectedAttachments[i].ToJObject(true), settings);
var receivedCard = AdaptiveCard.GetCardWithoutValues(receivedAttachments[i].ToJObject(true), settings);
logger.Information($"expected card: {expectedCard}");
logger.Information($"received card: {receivedCard}");
if (!expectedCard.Equals(receivedCard, StringComparison.InvariantCultureIgnoreCase))
{
return false;
Expand Down
18 changes: 17 additions & 1 deletion PVATestFramework/PVATestFramework/Models/Activities/Activity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ public static bool IsMessageActivityWithText(this Activity activity)

public class Attachment
{
public Attachment(string contentType, Object content)
{
ContentType = contentType;
Content = content;
}
[JsonProperty("contentType")]
public string ContentType { get; set; }

[JsonProperty("content")]
public Content Content { get; set; }
public Object Content { get; set; }
}

public class Action
Expand Down Expand Up @@ -119,6 +124,17 @@ public class Content
[JsonProperty("version")]
public string Version { get; set; }
}
public class BasicCardContent
{
[JsonProperty("title")]
public string Title { get; set; }

[JsonProperty("images")]
public List<string> Images { get; set; }

[JsonProperty("buttons")]
public List<string> Buttons { get; set; }
}

public class Data
{
Expand Down
25 changes: 25 additions & 0 deletions PVATestFramework/PVATestFramework/PVATestFramework.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PVATestFramework", "PVATestFramework.csproj", "{93399C26-6CC4-4C53-987B-166122B78300}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{93399C26-6CC4-4C53-987B-166122B78300}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{93399C26-6CC4-4C53-987B-166122B78300}.Debug|Any CPU.Build.0 = Debug|Any CPU
{93399C26-6CC4-4C53-987B-166122B78300}.Release|Any CPU.ActiveCfg = Release|Any CPU
{93399C26-6CC4-4C53-987B-166122B78300}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C68EE9E9-3236-418C-8F2F-23E9420EA006}
EndGlobalSection
EndGlobal