コード例 #1
0
        public void InvalidFormat_Returns_DefaultObject()
        {
            string str = "wrong format";

            byte[] strBytes            = Encoding.UTF8.GetBytes(str);
            BasicDeliverEventArgs args = new BasicDeliverEventArgs("tag", 1, false, "", "queue", null, strBytes);

            ILoggerFactory loggerFactory = new LoggerFactory();
            ILogger        logger        = loggerFactory.CreateLogger(LogCategories.CreateTriggerCategory("RabbitMQ"));
            BasicDeliverEventArgsToPocoConverter <TestClass> converter = new BasicDeliverEventArgsToPocoConverter <TestClass>(logger);
            TestClass actualObj = converter.Convert(args);

            Assert.Equal(default, actualObj);
        public void InvalidFormat_Throws_JsonException()
        {
            string str = "wrong format";

            byte[] strBytes            = Encoding.UTF8.GetBytes(str);
            BasicDeliverEventArgs args = new BasicDeliverEventArgs("tag", 1, false, "", "queue", null, strBytes);

            ILoggerFactory loggerFactory = new LoggerFactory();
            ILogger        logger        = loggerFactory.CreateLogger(LogCategories.CreateTriggerCategory("RabbitMQ"));
            BasicDeliverEventArgsToPocoConverter <TestClass> converter = new BasicDeliverEventArgsToPocoConverter <TestClass>(logger);

            Assert.Throws <JsonReaderException>(() => converter.Convert(args));
        }
コード例 #3
0
        public void Converts_to_Poco()
        {
            TestClass expectedObj = new TestClass(1, 1);

            string objJson = JsonConvert.SerializeObject(expectedObj);

            byte[] objJsonBytes        = Encoding.UTF8.GetBytes(objJson);
            BasicDeliverEventArgs args = new BasicDeliverEventArgs("tag", 1, false, "", "queue", null, objJsonBytes);

            ILoggerFactory loggerFactory = new LoggerFactory();
            ILogger        logger        = loggerFactory.CreateLogger(LogCategories.CreateTriggerCategory("RabbitMQ"));
            BasicDeliverEventArgsToPocoConverter <TestClass> converter = new BasicDeliverEventArgsToPocoConverter <TestClass>(logger);
            TestClass actualObj = converter.Convert(args);

            Assert.Equal(expectedObj.x, actualObj.x);
            Assert.Equal(expectedObj.y, actualObj.y);
        }