-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'stoiveyp-SkillConnections'
- Loading branch information
Showing
35 changed files
with
817 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "Tasks.CompleteTask", | ||
"status": { | ||
"code": 200, | ||
"message": "return as desired" | ||
} | ||
} |
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 @@ | ||
{ | ||
"type": "LaunchRequest", | ||
"requestId": "string", | ||
"timestamp": "2019-07-03T00:00:00", | ||
"locale": "string", | ||
"originIpAddress": "string", | ||
"task": { | ||
"name": "AMAZON.PrintPDF", | ||
"version": "1", | ||
"input": { | ||
"@type": "PrintPDFRequest", | ||
"@version": "1", | ||
"title": "Flywheel", | ||
"description": "Flywheel", | ||
"url": "http://www.example.com/flywheel.pdf" | ||
} | ||
} | ||
} |
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,12 @@ | ||
{ | ||
"type": "Connections.StartConnection", | ||
"uri": "connection://AMAZON.PrintImage/1", | ||
"input": { | ||
"@type": "PrintImageRequest", | ||
"@version": "1", | ||
"title": "Flywheel Document", | ||
"description": "Flywheel", | ||
"imageType": "JPEG", | ||
"url": "http://www.example.com/flywheel.jpeg" | ||
} | ||
} |
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,15 @@ | ||
{ | ||
"type": "Connections.StartConnection", | ||
"uri": "connection://AMAZON.PrintPDF/1", | ||
"input": { | ||
"@type": "PrintPDFRequest", | ||
"@version": "1", | ||
"title": "title", | ||
"description": "description", | ||
"context": { | ||
"providerId": "your-provider-skill-id" | ||
}, | ||
"url": "http://www.example.com/flywheel.pdf" | ||
}, | ||
"token": "none" | ||
} |
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,11 @@ | ||
{ | ||
"type": "Connections.StartConnection", | ||
"uri": "connection://AMAZON.PrintWebPage/1", | ||
"input": { | ||
"@type": "PrintWebPageRequest", | ||
"@version": "1", | ||
"title": "title", | ||
"description": "description", | ||
"url": "http://www.example.com/flywheel.html" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Alexa.NET.Tests/Examples/ScheduleFoodEstablishmentReservation.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,24 @@ | ||
{ | ||
"type": "Connections.StartConnection", | ||
"uri": "connection://AMAZON.ScheduleFoodEstablishmentReservation/1", | ||
"input": { | ||
"@type": "ScheduleFoodEstablishmentReservationRequest", | ||
"@version": "1", | ||
"startTime": "2018-04-08T01:15:46Z", | ||
"partySize": 2, | ||
"restaurant": { | ||
"@type": "Restaurant", | ||
"@version": "1", | ||
"name": "Amazon Day 1 Restaurant", | ||
"location": { | ||
"@type": "PostalAddress", | ||
"@version": "1", | ||
"streetAddress": "2121 7th Avenue", | ||
"locality": "Seattle", | ||
"region": "WA", | ||
"postalCode": "98121", | ||
"country": "US" | ||
} | ||
} | ||
} | ||
} |
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,27 @@ | ||
{ | ||
"type": "Connections.StartConnection", | ||
"uri": "connection://AMAZON.ScheduleTaxiReservation/1", | ||
"input": { | ||
"@type": "ScheduleTaxiReservationRequest", | ||
"@version": "1", | ||
"partySize": 4, | ||
"pickupLocation": { | ||
"@type": "PostalAddress", | ||
"@version": "1", | ||
"streetAddress": "415 106th Ave NE", | ||
"locality": "Bellevue", | ||
"region": "WA", | ||
"postalCode": "98004", | ||
"country": "US" | ||
}, | ||
"dropoffLocation": { | ||
"@type": "PostalAddress", | ||
"@version": "1", | ||
"streetAddress": "2031 6th Ave.", | ||
"locality": "Seattle", | ||
"region": "WA", | ||
"postalCode": "98121", | ||
"country": "US" | ||
} | ||
} | ||
} |
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,16 @@ | ||
{ | ||
"type": "SessionResumedRequest", | ||
"requestId": "string", | ||
"timestamp": "2019-07-03T00:00:00", | ||
"locale": "en-GB", | ||
"originIpAddress": "string", | ||
"cause": { | ||
"type": "ConnectionCompleted", | ||
"token": "1234", | ||
"status": { | ||
"code": 200, | ||
"message": "OK" | ||
}, | ||
"result": null | ||
} | ||
} |
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,184 @@ | ||
using System; | ||
using Alexa.NET.ConnectionTasks; | ||
using Alexa.NET.ConnectionTasks.Inputs; | ||
using Alexa.NET.Request.Type; | ||
using Alexa.NET.Response; | ||
using Alexa.NET.Response.Directive; | ||
using Xunit; | ||
|
||
namespace Alexa.NET.Tests | ||
{ | ||
public class SkillConnectionTests | ||
{ | ||
[Fact] | ||
public void StartConnectionDirectiveSerializesCorrectly() | ||
{ | ||
var task = new PrintPdfV1 | ||
{ | ||
Title = "title", | ||
Description = "description", | ||
Url = "http://www.example.com/flywheel.pdf", | ||
Context = new ConnectionTaskContext { ProviderId = "your-provider-skill-id" } | ||
}; | ||
Utility.CompareJson(task.ToConnectionDirective("none"), "PrintPDFConnection.json"); | ||
} | ||
|
||
[Fact] | ||
public void StartConnectionDirectiveDeserializesCorrectly() | ||
{ | ||
var raw = Utility.ExampleFileContent<IDirective>("PrintPDFConnection.json"); | ||
Assert.NotNull(raw); | ||
|
||
var directive = Assert.IsType<StartConnectionDirective>(raw); | ||
Assert.Equal("none", directive.Token); | ||
Assert.Equal(PrintPdfV1.AssociatedUri, directive.Uri); | ||
|
||
Assert.IsType<PrintPdfV1>(directive.Input); | ||
} | ||
|
||
[Fact] | ||
public void SessionResumedSerializesProperly() | ||
{ | ||
var task = new SessionResumedRequest | ||
{ | ||
RequestId = "string", | ||
Timestamp = new DateTime(2019, 07, 03), | ||
Locale = "en-GB", | ||
OriginIpAddress = "string", | ||
Cause = new SessionResumedRequestCause | ||
{ | ||
Type = "ConnectionCompleted", | ||
Token = "1234", | ||
Status = new TaskStatus(200, "OK") | ||
} | ||
}; | ||
Utility.CompareJson(task, "SessionResumedRequest.json"); | ||
} | ||
|
||
[Fact] | ||
public void SessionResumedDeserializesProperly() | ||
{ | ||
var result = Utility.ExampleFileContent<Request.Type.Request>("SessionResumedRequest.json"); | ||
var request = Assert.IsType<SessionResumedRequest>(result); | ||
|
||
Assert.Equal("1234", request.Cause.Token); | ||
Assert.Equal(200, request.Cause.Status.Code); | ||
Assert.Equal("OK", request.Cause.Status.Message); | ||
} | ||
|
||
[Fact] | ||
public void LaunchRequestWithTaskDeserializesCorrectly() | ||
{ | ||
var result = Utility.ExampleFileContent<LaunchRequest>("LaunchRequestWithTask.json"); | ||
Assert.NotNull(result.Task); | ||
Assert.Equal("AMAZON.PrintPDF", result.Task.Name); | ||
Assert.Equal("1", result.Task.Version); | ||
Assert.IsType<PrintPdfV1>(result.Task.Input); | ||
} | ||
|
||
[Fact] | ||
public void TestCompleteTaskDirective() | ||
{ | ||
var directive = new CompleteTaskDirective(200, "return as desired"); | ||
Assert.True(Utility.CompareJson(directive, "CompleteTaskDirective.json")); | ||
} | ||
|
||
[Fact] | ||
public void PrintImageConnectionComparison() | ||
{ | ||
var directive = new PrintImageV1 | ||
{ | ||
Title = "Flywheel Document", | ||
Description = "Flywheel", | ||
ImageV1Type = PrintImageV1Type.JPEG, | ||
Url = "http://www.example.com/flywheel.jpeg" | ||
}.ToConnectionDirective(); | ||
Assert.Equal(PrintImageV1.AssociatedUri, directive.Uri); | ||
Assert.True(Utility.CompareJson(directive, "PrintImageConnection.json")); | ||
Assert.IsType<PrintImageV1>(Utility.ExampleFileContent<StartConnectionDirective>("PrintImageConnection.json").Input); | ||
} | ||
|
||
[Fact] | ||
public void PrintPDFConnectionComparison() | ||
{ | ||
var directive = new PrintPdfV1 | ||
{ | ||
Title = "title", | ||
Description = "description", | ||
Url = "http://www.example.com/flywheel.pdf", | ||
Context = new ConnectionTaskContext { ProviderId = "your-provider-skill-id" } | ||
}.ToConnectionDirective("none"); | ||
Assert.Equal(PrintPdfV1.AssociatedUri, directive.Uri); | ||
Assert.True(Utility.CompareJson(directive, "PrintPDFConnection.json")); | ||
Assert.IsType<PrintPdfV1>(Utility.ExampleFileContent<StartConnectionDirective>("PrintPDFConnection.json").Input); | ||
} | ||
|
||
[Fact] | ||
public void PrintWebPageConnectionComparison() | ||
{ | ||
var directive = new PrintWebPageV1 | ||
{ | ||
Title = "title", | ||
Description = "description", | ||
Url = "http://www.example.com/flywheel.html" | ||
}.ToConnectionDirective(); | ||
Assert.Equal(PrintWebPageV1.AssociatedUri, directive.Uri); | ||
Assert.True(Utility.CompareJson(directive, "PrintWebPageConnection.json")); | ||
Assert.IsType<PrintPdfV1>(Utility.ExampleFileContent<StartConnectionDirective>("PrintPDFConnection.json").Input); | ||
} | ||
|
||
[Fact] | ||
public void ScheduleTaxiReservationConnectionComparison() | ||
{ | ||
var directive = new ScheduleTaxiReservation | ||
{ | ||
PartySize = 4, | ||
PickupLocation = new PostalAddress | ||
{ | ||
StreetAddress = "415 106th Ave NE", | ||
Locality = "Bellevue", | ||
Region = "WA", | ||
PostalCode = "98004", | ||
Country = "US" | ||
}, | ||
DropoffLocation = new PostalAddress | ||
{ | ||
StreetAddress = "2031 6th Ave.", | ||
Locality = "Seattle", | ||
Region = "WA", | ||
PostalCode = "98121", | ||
Country = "US" | ||
} | ||
}.ToConnectionDirective(); | ||
Assert.Equal(ScheduleTaxiReservation.AssociatedUri, directive.Uri); | ||
Assert.True(Utility.CompareJson(directive, "ScheduleTaxiReservation.json")); | ||
Assert.IsType<ScheduleTaxiReservation>(Utility.ExampleFileContent<StartConnectionDirective>("ScheduleTaxiReservation.json").Input); | ||
} | ||
|
||
[Fact] | ||
public void ScheduleFoodReservationConnectionComparison() | ||
{ | ||
var directive = new ScheduleFoodEstablishmentReservation | ||
{ | ||
PartySize = 2, | ||
StartTime = new DateTime(2018,04,08,01,15,46), | ||
Restaurant = new Restaurant | ||
{ | ||
Name = "Amazon Day 1 Restaurant", | ||
Location = new PostalAddress | ||
{ | ||
StreetAddress = "2121 7th Avenue", | ||
Locality = "Seattle", | ||
Region = "WA", | ||
PostalCode = "98121", | ||
Country = "US" | ||
} | ||
} | ||
}.ToConnectionDirective(); | ||
Assert.Equal(ScheduleFoodEstablishmentReservation.AssociatedUri, directive.Uri); | ||
Assert.True(Utility.CompareJson(directive, "ScheduleFoodEstablishmentReservation.json")); | ||
Assert.IsType<ScheduleFoodEstablishmentReservation>(Utility.ExampleFileContent<StartConnectionDirective>("ScheduleFoodEstablishmentReservation.json").Input); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.