Exemplo n.º 1
0
        public void ConverterConvertsFromValueTypes_ObjectWithJsonConverter()
        {
            using (var rt = BaristaRuntimeFactory.CreateRuntime())
            {
                using (var ctx = rt.CreateContext())
                {
                    using (ctx.Scope())
                    {
                        var converter = new BaristaConversionStrategy(new JsonNetConverter());

                        converter.TryFromObject(ctx, new MyStruct("bar", 42), out JsValue value);
                        var obj = value as JsObject;
                        Assert.NotNull(obj);

                        Assert.Equal("bar", obj["Foo"].ToString());
                        Assert.Equal(42, obj["Bar"].ToDouble());
                    }
                }
            }
        }
Exemplo n.º 2
0
 public void ConverterCanBeConstructedWithJsonConverter()
 {
     var converter = new BaristaConversionStrategy(new JsonNetConverter());
 }