public void IgnorePropertiesWithErrors()
        {
            var loggerMock = new Mock<ILogger>();

            ISerializer serializer = new JsonNetSerializer(loggerMock.Object);

            var badObject = new TestObjectWithException();

            string result = serializer.Serialize(badObject);

            Assert.Equal("{\"string\":\"A string\"}", result);
            //This verify is not registered due to lambda. It has been verified to work
            //loggerMock.Verify(l=>l.Error(It.IsAny<string>(), It.IsAny<NotSupportedException>()));
        }
示例#2
0
        public void IgnorePropertiesWithErrors()
        {
            var loggerMock = new Mock <ILogger>();

            ISerializer serializer = new JsonNetSerializer(loggerMock.Object);

            var badObject = new TestObjectWithException();

            string result = serializer.Serialize(badObject);

            Assert.Equal("{\"string\":\"A string\"}", result);
            //This verify is not registered due to lambda. It has been verified to work
            //loggerMock.Verify(l=>l.Error(It.IsAny<string>(), It.IsAny<NotSupportedException>()));
        }
        public void IgnorePropertiesWithErrors()
        {
            var loggerMock = new Mock <ILogger>();

            ISerializer serializer = new JsonNetSerializer(loggerMock.Object);

            var badObject = new TestObjectWithException();

            string result = serializer.Serialize(badObject);

            Assert.Equal("{\"string\":\"A string\"}", result);
            loggerMock.Verify(l => l.Error(It.IsAny <string>(),
                                           It.Is <JsonException>(ex => ex.InnerException is NotSupportedException)));
        }
        public void IgnorePropertiesWithErrors()
        {
            var loggerMock = new Mock<ILogger>();

            ISerializer serializer = new JsonNetSerializer(loggerMock.Object);

            var badObject = new TestObjectWithException();

            string result = serializer.Serialize(badObject);

            Assert.Equal("{\"string\":\"A string\"}", result);
            loggerMock.Verify(l => l.Error(It.IsAny<string>(),
                                           It.Is<JsonException>(ex => ex.InnerException is NotSupportedException)));
        }