public void Given_Value_When_WriteJson_Invoked_THen_It_Should_Throw()
        {
            var converter = new ActionConverter();

            Action action = () => converter.WriteJson(null, null, null);

            action.Should().Throw <NotImplementedException>();
        }
        public void Given_Type_When_CanConvert_Invoked_It_Should_Return(Type type, bool expected)
        {
            var converter = new ActionConverter();

            var result = converter.CanConvert(type);

            result.Should().Be(expected);
        }
        public void Given_Json_Value_When_ReadJson_Invoked_Then_It_Should_Return(string json, Type expected)
        {
            var serialiser = new JsonSerializer();
            var result     = default(object);

            var converter = new ActionConverter();

            using (var reader = new StringReader(json))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    result = converter.ReadJson(jsonReader, null, null, serialiser);
                }

            result.Should().BeOfType(expected);
        }
Exemple #4
0
        protected void initFieldMapping(List <string> NoMapping = null)
        {
            PropertyInfo[] properties  = this.GetType().GetProperties();
            FieldInfo[]    properties2 = this.GetType().GetFields();
            log.Debug(properties2);
            log.Debug(properties);

            foreach (PropertyInfo propertie in properties)
            {
                if ((NoMapping == null) || (!NoMapping.Contains(propertie.Name)))
                {
                    FieldMapping.Add(propertie.Name, new VariableReference(
                                         () => propertie.GetValue(this),
                                         ActionConverter.getAction(this, propertie.PropertyType.ToString(), propertie)
                                         ));
                    log.DebugFormat("added {0} to FieldMapping", propertie.Name);
                }
                else
                {
                    log.DebugFormat("found {0} in List for Special Mapping", propertie.Name);
                }
            }
        }