Skip to content

Commit 2e2fd43

Browse files
committed
Tests for 2nd parameter missing while first parameter is passed
1 parent 5695c55 commit 2e2fd43

2 files changed

Lines changed: 197 additions & 0 deletions

File tree

AustinHarris.JsonRpcTest/UnitTest1.cs

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,136 @@ public void TestOptionalParamdecimalMissingObjectSyntax()
734734
Assert.AreEqual(expectedResult, result.Result);
735735
}
736736

737+
[TestMethod]
738+
public void TestOptionalParambyte_2ndMissingObjectSyntax()
739+
{
740+
string request = @"{method:'TestOptionalParambyte_2x',params:{input1:123},id:1}";
741+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":98,\"id\":1}";
742+
var result = InProcessClient.Invoke(request);
743+
result.Wait();
744+
Assert.IsFalse(result.Result.Contains("error"));
745+
Assert.AreEqual(expectedResult, result.Result);
746+
}
747+
[TestMethod]
748+
public void TestOptionalParamsbyte_2ndMissingObjectSyntax()
749+
{
750+
string request = @"{method:'TestOptionalParamsbyte_2x',params:{input1:123},id:1}";
751+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":126,\"id\":1}";
752+
var result = InProcessClient.Invoke(request);
753+
result.Wait();
754+
Assert.IsFalse(result.Result.Contains("error"));
755+
Assert.AreEqual(expectedResult, result.Result);
756+
}
757+
[TestMethod]
758+
public void TestOptionalParamshort_2ndMissingObjectSyntax()
759+
{
760+
string request = @"{method:'TestOptionalParamshort_2x',params:{input1:123},id:1}";
761+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
762+
var result = InProcessClient.Invoke(request);
763+
result.Wait();
764+
Assert.IsFalse(result.Result.Contains("error"));
765+
Assert.AreEqual(expectedResult, result.Result);
766+
}
767+
[TestMethod]
768+
public void TestOptionalParamint_2ndMissingObjectSyntax()
769+
{
770+
string request = @"{method:'TestOptionalParamint_2x',params:{input1:123},id:1}";
771+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
772+
var result = InProcessClient.Invoke(request);
773+
result.Wait();
774+
Assert.IsFalse(result.Result.Contains("error"));
775+
Assert.AreEqual(expectedResult, result.Result);
776+
}
777+
[TestMethod]
778+
public void TestOptionalParamlong_2ndMissingObjectSyntax()
779+
{
780+
string request = @"{method:'TestOptionalParamlong_2x',params:{input1:123},id:1}";
781+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
782+
var result = InProcessClient.Invoke(request);
783+
result.Wait();
784+
Assert.IsFalse(result.Result.Contains("error"));
785+
Assert.AreEqual(expectedResult, result.Result);
786+
}
787+
[TestMethod]
788+
public void TestOptionalParamushort_2ndMissingObjectSyntax()
789+
{
790+
string request = @"{method:'TestOptionalParamushort_2x',params:{input1:123},id:1}";
791+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
792+
var result = InProcessClient.Invoke(request);
793+
result.Wait();
794+
Assert.IsFalse(result.Result.Contains("error"));
795+
Assert.AreEqual(expectedResult, result.Result);
796+
}
797+
[TestMethod]
798+
public void TestOptionalParamuint_2ndMissingObjectSyntax()
799+
{
800+
string request = @"{method:'TestOptionalParamuint_2x',params:{input1:123},id:1}";
801+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
802+
var result = InProcessClient.Invoke(request);
803+
result.Wait();
804+
Assert.IsFalse(result.Result.Contains("error"));
805+
Assert.AreEqual(expectedResult, result.Result);
806+
}
807+
[TestMethod]
808+
public void TestOptionalParamulong_2ndMissingObjectSyntax()
809+
{
810+
string request = @"{method:'TestOptionalParamulong_2x',params:{input1:123},id:1}";
811+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
812+
var result = InProcessClient.Invoke(request);
813+
result.Wait();
814+
Assert.IsFalse(result.Result.Contains("error"));
815+
Assert.AreEqual(expectedResult, result.Result);
816+
}
817+
[TestMethod]
818+
public void TestOptionalParamfloat_2ndMissingObjectSyntax()
819+
{
820+
string request = @"{method:'TestOptionalParamfloat_2x',params:{input1:123},id:1}";
821+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987.0,\"id\":1}";
822+
var result = InProcessClient.Invoke(request);
823+
result.Wait();
824+
Assert.IsFalse(result.Result.Contains("error"));
825+
Assert.AreEqual(expectedResult, result.Result);
826+
}
827+
[TestMethod]
828+
public void TestOptionalParamdouble_2ndMissingObjectSyntax()
829+
{
830+
string request = @"{method:'TestOptionalParamdouble_2x',params:{input1:123},id:1}";
831+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987.0,\"id\":1}";
832+
var result = InProcessClient.Invoke(request);
833+
result.Wait();
834+
Assert.IsFalse(result.Result.Contains("error"));
835+
Assert.AreEqual(expectedResult, result.Result);
836+
}
837+
[TestMethod]
838+
public void TestOptionalParambool_2ndMissingObjectSyntax()
839+
{
840+
string request = @"{method:'TestOptionalParambool_2x',params:{input1:123},id:1}";
841+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":true,\"id\":1}";
842+
var result = InProcessClient.Invoke(request);
843+
result.Wait();
844+
Assert.IsFalse(result.Result.Contains("error"));
845+
Assert.AreEqual(expectedResult, result.Result);
846+
}
847+
[TestMethod]
848+
public void TestOptionalParamchar_2ndMissingObjectSyntax()
849+
{
850+
string request = @"{method:'TestOptionalParamchar_2x',params:{input1:123},id:1}";
851+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"d\",\"id\":1}";
852+
var result = InProcessClient.Invoke(request);
853+
result.Wait();
854+
Assert.IsFalse(result.Result.Contains("error"));
855+
Assert.AreEqual(expectedResult, result.Result);
856+
}
857+
[TestMethod]
858+
public void TestOptionalParamdecimal_2ndMissingObjectSyntax()
859+
{
860+
string request = @"{method:'TestOptionalParamdecimal_2x',params:{input1:123},id:1}";
861+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987.0,\"id\":1}";
862+
var result = InProcessClient.Invoke(request);
863+
result.Wait();
864+
Assert.IsFalse(result.Result.Contains("error"));
865+
Assert.AreEqual(expectedResult, result.Result);
866+
}
737867

738868
}
739869
}

AustinHarris.JsonRpcTest/service.cs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,72 @@ private decimal TestOptionalParamdecimal(decimal input = 1)
212212

213213
#endregion
214214

215+
[JsonRpcMethod]
216+
public byte TestOptionalParambyte_2x(byte input1, byte input2 = 98)
217+
{
218+
return input2;
219+
}
220+
[JsonRpcMethod]
221+
public sbyte TestOptionalParamsbyte_2x(sbyte input1, sbyte input2 = 126)
222+
{
223+
return input2;
224+
}
225+
[JsonRpcMethod]
226+
public short TestOptionalParamshort_2x(short input1, short input2 = 987)
227+
{
228+
return input2;
229+
}
230+
[JsonRpcMethod]
231+
public int TestOptionalParamint_2x(int input1, int input2 = 987)
232+
{
233+
return input2;
234+
}
235+
[JsonRpcMethod]
236+
public long TestOptionalParamlong_2x(long input1, long input2 = 987)
237+
{
238+
return input2;
239+
}
240+
[JsonRpcMethod]
241+
public ushort TestOptionalParamushort_2x(ushort input1, ushort input2 = 987)
242+
{
243+
return input2;
244+
}
245+
[JsonRpcMethod]
246+
public uint TestOptionalParamuint_2x(uint input1, uint input2 = 987)
247+
{
248+
return input2;
249+
}
250+
[JsonRpcMethod]
251+
public ulong TestOptionalParamulong_2x(ulong input1, ulong input2 = 987)
252+
{
253+
return input2;
254+
}
255+
[JsonRpcMethod]
256+
public float TestOptionalParamfloat_2x(float input1, float input2 = 987)
257+
{
258+
return input2;
259+
}
260+
[JsonRpcMethod]
261+
public double TestOptionalParamdouble_2x(double input1, double input2 = 987)
262+
{
263+
return input2;
264+
}
265+
[JsonRpcMethod]
266+
public bool TestOptionalParambool_2x(bool input1, bool input2 = true)
267+
{
268+
return input2;
269+
}
270+
[JsonRpcMethod]
271+
public char TestOptionalParamchar_2x(char input1, char input2 = 'd')
272+
{
273+
return input2;
274+
}
275+
[JsonRpcMethod]
276+
public decimal TestOptionalParamdecimal_2x(decimal input1, decimal input2 = 987)
277+
{
278+
return input2;
279+
}
280+
281+
215282
}
216283
}

0 commit comments

Comments
 (0)