コード例 #1
0
        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));
        }
コード例 #2
0
        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)));
        }
コード例 #3
0
        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"));
        }
コード例 #4
0
        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"));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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",
                                                                 @"}",
                                                                 @")",
                                                                 @"")));
        }
コード例 #8
0
        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));
        }