public void AppendArgumentsForEmptyArguments() { object[] args = new object[0]; var paramInfo = InvocationLogUtilTest_Hepler.CreateParameters(); logUtil.AppendArgumentsJson(stringBuilder, paramInfo, args); Assert.That(stringBuilder.ToString(), Is.EqualTo("()" + Environment.NewLine)); }
public void ReferenceLoopsReturn() { var args = new object[] { new SelfReferentialObj() }; var paramInfo = InvocationLogUtilTest_Hepler.CreateParameters("param1"); logUtil.AppendArgumentsJson(stringBuilder, paramInfo, args); Assert.That(stringBuilder.ToString(), Does.Contain(@"""Number"": 5")); Assert.That(stringBuilder.ToString(), Does.Contain("Self referencing loop detected")); Assert.That(stringBuilder.ToString(), Does.Contain(nameof(SelfReferentialObj))); Assert.That(stringBuilder.ToString(), Does.Contain(nameof(SelfReferentialObj.SelfReference))); }
public void ErrorObjectSerialization() { var args = new object[] { new ErrorObj(), 9 }; var paramInfo = InvocationLogUtilTest_Hepler.CreateParameters("param1", "param2"); logUtil.AppendArgumentsJson(stringBuilder, paramInfo, args); Assert.That(stringBuilder.ToString(), Does.Contain(@"""Number"": 7")); Assert.That(stringBuilder.ToString(), Does.Contain("ExceptionThrowingProperty")); Assert.That(stringBuilder.ToString(), Does.Contain("Dummy Exception Message")); Assert.That(stringBuilder.ToString(), Does.Contain("\"param2\": 9")); }
public void ErrorObjectSerialization() { var args = new object[] { new ErrorObj() }; var param1 = Substitute.For <ParameterInfo>(); param1.Name.Returns("param1"); var paramInfo = InvocationLogUtilTest_Hepler.CreateParameters( "param1"); logUtil.AppendArgumentsToString(stringBuilder, paramInfo, args); Assert.That(stringBuilder.ToString(), Does.Contain("param1=<Unknown>")); Assert.That(stringBuilder.ToString(), Does.Contain("Dummy Exception Message")); }
public void AppendArgumentsForOneArg() { object[] args = new object[] { 1 }; var paramInfo = InvocationLogUtilTest_Hepler.CreateParameters("param1"); logUtil.AppendArgumentsJson(stringBuilder, paramInfo, args); var expected = JoinLines( @"(", @"{", @" ""param1"": 1", @"}", @")", @""); Assert.That(stringBuilder.ToString(), Is.EqualTo(expected)); }
public void ComplexObjectSerialization() { var args = new object[] { new ArrayObj(), new ComplexObj() }; var paramInfo = InvocationLogUtilTest_Hepler.CreateParameters("param1", "param2"); logUtil.AppendArgumentsJson(stringBuilder, paramInfo, args); var expected = JoinLines( @"(", @"{", @" ""param1"": {", @" ""Numbers"": [", @" 1,", @" 2,", @" 3", @" ]", @" },", @" ""param2"": {", @" ""SimpleObj"": {", @" ""Number"": 9", @" },", @" ""ArrayObj"": {", @" ""Numbers"": [", @" 1,", @" 2,", @" 3", @" ]", @" }", @" }", @"}", @")", @""); Assert.That(stringBuilder.ToString(), Is.EqualTo(expected)); }
public void AppendArgumentsForSomeArg() { object[] args = new object[] { 1, "value", null }; var paramInfo = InvocationLogUtilTest_Hepler.CreateParameters( "param1", "param2", "param3"); logUtil.AppendArgumentsJson(stringBuilder, paramInfo, args); Assert.That(stringBuilder.ToString(), Is.EqualTo(JoinLines( @"(", @"{", @" ""param1"": 1,", @" ""param2"": ""value"",", @" ""param3"": null", @"}", @")", @""))); }
public void MultipleArgSerialization() { var args = new object[] { 100, "value2", null }; var paramInfo = InvocationLogUtilTest_Hepler.CreateParameters( "param1", "param2", "param3"); logUtil.AppendArgumentsToString(stringBuilder, paramInfo, args); var expectedLog = JoinLines( @"(", @" param1=100,", @" param2=value2,", @" param3=null", @")", @""); Assert.That(stringBuilder.ToString(), Is.EqualTo(expectedLog)); }