-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #275 from AArnott/fix272
Allow non-array lists of arguments
- Loading branch information
Showing
7 changed files
with
111 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Collections.Generic; | ||
using StreamJsonRpc.Protocol; | ||
using Xunit; | ||
|
||
public class JsonRpcRequestTests | ||
{ | ||
private static readonly IReadOnlyList<object> ArgumentsAsList = new List<object> { 4, 6, 8 }; | ||
private static readonly IReadOnlyList<object> ArgumentsAsArray = new object[] { 4, 6, 8 }; | ||
private static readonly object ArgumentsAsObject = new Dictionary<string, object> { { "Foo", 4 }, { "bar", 6 } }; | ||
|
||
[Fact] | ||
public void ArgumentsCount_WithNamedArguments() | ||
{ | ||
var request = new JsonRpcRequest | ||
{ | ||
Arguments = ArgumentsAsObject, | ||
}; | ||
Assert.Equal(2, request.ArgumentCount); | ||
} | ||
|
||
[Fact] | ||
public void ArgumentsCount_WithList() | ||
{ | ||
var request = new JsonRpcRequest | ||
{ | ||
Arguments = ArgumentsAsList, | ||
}; | ||
Assert.Equal(3, request.ArgumentCount); | ||
} | ||
|
||
[Fact] | ||
public void ArgumentsCount_WithArray() | ||
{ | ||
var request = new JsonRpcRequest | ||
{ | ||
Arguments = ArgumentsAsArray, | ||
}; | ||
Assert.Equal(3, request.ArgumentCount); | ||
} | ||
|
||
[Fact] | ||
public void ArgumentsList() | ||
{ | ||
var request = new JsonRpcRequest | ||
{ | ||
Arguments = ArgumentsAsList, | ||
}; | ||
Assert.Same(request.Arguments, request.ArgumentsList); | ||
Assert.Same(ArgumentsAsList, request.ArgumentsList); | ||
} | ||
|
||
#pragma warning disable CS0618 // Type or member is obsolete | ||
[Fact] | ||
public void ArgumentsArray_WithArray() | ||
{ | ||
var request = new JsonRpcRequest | ||
{ | ||
Arguments = ArgumentsAsArray, | ||
}; | ||
Assert.Same(request.Arguments, request.ArgumentsArray); | ||
Assert.Same(ArgumentsAsArray, request.ArgumentsArray); | ||
} | ||
|
||
[Fact] | ||
public void ArgumentsArray_WithList() | ||
{ | ||
var request = new JsonRpcRequest | ||
{ | ||
Arguments = ArgumentsAsList, | ||
}; | ||
Assert.Null(request.ArgumentsArray); | ||
} | ||
#pragma warning restore CS0618 // Type or member is obsolete | ||
} |
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,2 @@ | ||
StreamJsonRpc.Protocol.JsonRpcRequest.ArgumentsList.get -> System.Collections.Generic.IReadOnlyList<object> | ||
StreamJsonRpc.Protocol.JsonRpcRequest.ArgumentsList.set -> void |