-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test sample and removed some warnings
- Loading branch information
Showing
330 changed files
with
33,951 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
@using Microsoft.Extensions.Hosting | ||
@using Newtonsoft.Json | ||
@using SharedCards.Cards.NugetSearch | ||
@using Microsoft.Bot.Schema.Teams | ||
@inherits CardView<CardApp> | ||
|
||
<Card Version="1.4"> | ||
<ColumnSet Spacing="AdaptiveSpacing.None" Style="AdaptiveContainerStyle.Emphasis" Bleed="true"> | ||
<Column Width="AdaptiveWidth.Stretch"> | ||
<InputChoiceSet Binding="Index" Label="" Style="AdaptiveChoiceInputStyle.Filtered" Placeholder="Choose card"> | ||
<DataQuery Dataset="Files" /> | ||
</InputChoiceSet> | ||
</Column> | ||
<Column Width="AdaptiveWidth.Auto"> | ||
<ActionSet> | ||
<ActionExecute Verb="@nameof(OnShowCard)" AssociatedInputs="@AdaptiveAssociatedInputs.Auto" Title="Show Card" /> | ||
</ActionSet> | ||
</Column> | ||
</ColumnSet> | ||
</Card> | ||
|
||
|
||
@code | ||
{ | ||
public string? Index { get; set; } | ||
|
||
[TempMemory] | ||
public AdaptiveCard? TestCard { get; set; } = null; | ||
|
||
public void OnShowCard() | ||
{ | ||
// get file card | ||
if (Index != null) | ||
{ | ||
var index = int.Parse(Index); | ||
var choice = GetFileChoices(null, index, 1)[0]; | ||
string root = Path.GetDirectoryName(this.GetType().Assembly.Location); | ||
var path = Path.Combine(root, "Cards", "Tests", choice.Title); | ||
var json = System.IO.File.ReadAllText(path); | ||
TestCard = JsonConvert.DeserializeObject<AdaptiveCard>(json); | ||
} | ||
} | ||
|
||
public async override Task<AdaptiveCard> RenderCardAsync(bool isPreview, CancellationToken cancellationToken) | ||
{ | ||
var card = await base.RenderCardAsync(isPreview, cancellationToken); | ||
|
||
if (TestCard != null) | ||
{ | ||
// merge | ||
foreach (var element in TestCard.Body) | ||
card.Body.Add(element); | ||
|
||
foreach (var action in TestCard.Actions) | ||
card.Actions.Add(action); | ||
} | ||
|
||
return card; | ||
} | ||
|
||
public override async Task<AdaptiveChoice[]> OnSearchChoicesAsync(SearchInvoke search, CancellationToken cancellationToken) | ||
{ | ||
await Task.CompletedTask; | ||
|
||
if (search.Dataset == "Files") | ||
{ | ||
return GetFileChoices(search.QueryText, search.QueryOptions.Skip, search.QueryOptions.Top); | ||
} | ||
return Array.Empty<AdaptiveChoice>(); | ||
} | ||
|
||
private AdaptiveChoice[] GetFileChoices(string query, int skip, int top) | ||
{ | ||
//get the full location of the assembly with DaoTests in it | ||
string root = Path.GetDirectoryName(this.GetType().Assembly.Location); | ||
int i = 0; | ||
var folder = Path.Combine(root, App.Route.Route.TrimStart('/').Replace('/', Path.DirectorySeparatorChar)); | ||
return Directory.EnumerateFiles(folder, "*.json", SearchOption.AllDirectories) | ||
.Select(p => | ||
{ | ||
var title = Path.GetRelativePath(root, p).Substring("Cards\\Tests\\".Length); | ||
return new AdaptiveChoice() | ||
{ | ||
Title = title, | ||
Value = i++.ToString() | ||
}; | ||
}) | ||
.Where(choice => choice.Title.Contains(query?.Trim() ?? String.Empty, StringComparison.OrdinalIgnoreCase)) | ||
.Skip(skip) | ||
.Take(top) | ||
.ToArray(); | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
source/samples/SharedCards/Cards/Tests/v1.0/Elements/Action.OpenUrl.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json", | ||
"type": "AdaptiveCard", | ||
"version": "1.0", | ||
"body": [ | ||
{ | ||
"type": "TextBlock", | ||
"text": "This card's action will open a URL" | ||
} | ||
], | ||
"actions": [ | ||
{ | ||
"type": "Action.OpenUrl", | ||
"title": "Action.OpenUrl", | ||
"url": "https://adaptivecards.io" | ||
} | ||
] | ||
} |
54 changes: 54 additions & 0 deletions
54
source/samples/SharedCards/Cards/Tests/v1.0/Elements/Action.ShowCard.Style.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json", | ||
"type": "AdaptiveCard", | ||
"version": "1.0", | ||
"body": [ | ||
{ | ||
"type": "TextBlock", | ||
"text": "This card's action will show another card" | ||
} | ||
], | ||
"actions": [ | ||
{ | ||
"type": "Action.ShowCard", | ||
"title": "No Style", | ||
"card": { | ||
"type": "AdaptiveCard", | ||
"body": [ | ||
{ | ||
"type": "TextBlock", | ||
"text": "This card has no style" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Action.ShowCard", | ||
"title": "Default Style", | ||
"card": { | ||
"type": "AdaptiveCard", | ||
"style": "default", | ||
"body": [ | ||
{ | ||
"type": "TextBlock", | ||
"text": "This card has default style" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Action.ShowCard", | ||
"title": "Emphasis Style", | ||
"card": { | ||
"type": "AdaptiveCard", | ||
"style": "emphasis", | ||
"body": [ | ||
{ | ||
"type": "TextBlock", | ||
"text": "This card has emphasis style" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.