public void RowToBean() { IBeanFactory factory = new BeanFactory(); factory.Options.ValidateGetColumns = false; var crud = new BeanCrud(new InMemoryStorage(), null, null, factory); var observer = new TracingObserver(); crud.AddObserver(observer); var bean = crud.RowToBean <Tracer>(new Dictionary <string, object> { { "s", "hello" } }); Assert.Null(bean["id"]); Assert.Equal("hello", bean["s"]); Assert.Equal("ad: bl: al:", bean.TraceLog); Assert.Equal("ad: bl: al:", observer.TraceLog); observer.TraceLog = ""; bean = crud.RowToBean <Tracer>(new Dictionary <string, object> { { "id", 123 }, { "s", "see you" } }); Assert.Equal(123, bean["id"]); Assert.Equal("see you", bean["s"]); Assert.Equal("ad: bl: al:123", bean.TraceLog); Assert.Equal("ad: bl: al:123", observer.TraceLog); Assert.Null(crud.Load("temp", null)); }
public void RowToBean() { var crud = new BeanCrud(new InMemoryStorage(), null, null); var observer = new TracingObserver(); crud.AddObserver(observer); var bean = crud.RowToBean<Tracer>(new Dictionary<string, object> { { "s", "hello" } }); Assert.Null(bean["id"]); Assert.Equal("hello", bean["s"]); Assert.Equal("ad: bl: al:", bean.TraceLog); Assert.Equal("ad: bl: al:", observer.TraceLog); observer.TraceLog = ""; bean = crud.RowToBean<Tracer>(new Dictionary<string, object> { { "id", 123 }, { "s", "see you" } }); Assert.Equal(123, bean["id"]); Assert.Equal("see you", bean["s"]); Assert.Equal("ad: bl: al:123", bean.TraceLog); Assert.Equal("ad: bl: al:123", observer.TraceLog); Assert.Null(crud.Load("temp", null)); }