public void ConvertItemsWithNullType()
        {
            List<SessionModel> sessionModels = new List<SessionModel>
                {
                    new SessionModel
                        {
                            Key = "Key1",
                            Value = "Test Value"
                        }
                };

            object rows = new SessionModelConverter().Convert(sessionModels);
            List<object> columns = GetFirstValueRowFromConvertedSessionModel(rows);

            Assert.Equal(columns[0], "Key1");
            Assert.Equal(columns[1], "Test Value");
            Assert.Equal(columns[2], null);
        }
Beispiel #2
0
        public void ConvertItemsWithNullType()
        {
            List <SessionModel> sessionModels = new List <SessionModel>
            {
                new SessionModel
                {
                    Key   = "Key1",
                    Value = "Test Value"
                }
            };

            object        rows    = new SessionModelConverter().Convert(sessionModels);
            List <object> columns = GetFirstValueRowFromConvertedSessionModel(rows);

            Assert.Equal(columns[0], "Key1");
            Assert.Equal(columns[1], "Test Value");
            Assert.Equal(columns[2], null);
        }
        public void ConvertNonSerializableItemsWithToStringMethod()
        {
            NonSerializableTestObjectWithToString testObject = new NonSerializableTestObjectWithToString { TestProperty = "Test Value" };

            List<SessionModel> sessionModels = new List<SessionModel>
                {
                    new SessionModel
                        {
                            Key = "Key1",
                            Value = testObject,
                            Type = testObject.GetType()
                        }
                };

            object rows = new SessionModelConverter().Convert(sessionModels);
            List<object> columns = GetFirstValueRowFromConvertedSessionModel(rows);

            Assert.Equal(columns[0], "Key1");
            Assert.Equal(columns[1], testObject.TestProperty);
            Assert.Equal(columns[2], typeof(NonSerializableTestObjectWithToString));
        }
        public void ConvertSerializableItems()
        {
            SerializableTestObject testObject = new SerializableTestObject { TestProperty = "Test Value" };

            List<SessionModel> sessionModels = new List<SessionModel>
                {
                    new SessionModel
                        {
                            Key = "Key1",
                            Value = testObject,
                            Type = testObject.GetType()
                        }
                };

            object rows = new SessionModelConverter().Convert(sessionModels);
            List<object> columns = GetFirstValueRowFromConvertedSessionModel(rows);

            Assert.Equal(columns[0], "Key1");
            Assert.Equal(columns[1], testObject);
            Assert.Equal(columns[2], typeof(SerializableTestObject));
        }
Beispiel #5
0
        public void FailToConvertNonSerializableItems()
        {
            NonSerializableTestObject testObject = new NonSerializableTestObject {
                TestProperty = "Test Value"
            };

            List <SessionModel> sessionModels = new List <SessionModel>
            {
                new SessionModel
                {
                    Key   = "Key1",
                    Value = testObject,
                    Type  = testObject.GetType()
                }
            };

            object        rows    = new SessionModelConverter().Convert(sessionModels);
            List <object> columns = GetFirstValueRowFromConvertedSessionModel(rows);

            Assert.Equal(columns[0], "Key1");
            Assert.Equal(columns[1], "\\Non serializable type :(\\");
            Assert.Equal(columns[2], typeof(NonSerializableTestObject));
        }
Beispiel #6
0
        public void ConvertNonSerializableItemsWithToStringMethod()
        {
            NonSerializableTestObjectWithToString testObject = new NonSerializableTestObjectWithToString {
                TestProperty = "Test Value"
            };

            List <SessionModel> sessionModels = new List <SessionModel>
            {
                new SessionModel
                {
                    Key   = "Key1",
                    Value = testObject,
                    Type  = testObject.GetType()
                }
            };

            object        rows    = new SessionModelConverter().Convert(sessionModels);
            List <object> columns = GetFirstValueRowFromConvertedSessionModel(rows);

            Assert.Equal(columns[0], "Key1");
            Assert.Equal(columns[1], testObject.TestProperty);
            Assert.Equal(columns[2], typeof(NonSerializableTestObjectWithToString));
        }