public void Trash() { IBeanFactory factory = new BeanFactory(); factory.Options.ValidateGetColumns = false; var crud = new BeanCrud(new InMemoryStorage(), null, new KeyUtil(), factory); var observer = new TracingObserver(); crud.AddObserver(observer); var bean = crud.Dispense <Tracer>(); observer.TraceLog = bean.TraceLog = ""; crud.Trash(bean); Assert.Empty(bean.TraceLog); Assert.Empty(observer.TraceLog); var id = crud.Store(bean); observer.TraceLog = bean.TraceLog = ""; crud.Trash(bean); Assert.Equal("bt:" + id + " at:" + id, bean.TraceLog); Assert.Equal("bt:" + id + " at:" + id, observer.TraceLog); Assert.Equal(id, bean["id"]); Assert.Null(crud.Load <Tracer>(id)); }
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)); }
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 Load() { IBeanFactory factory = new BeanFactory(); factory.Options.ValidateGetColumns = false; var crud = new BeanCrud(new InMemoryStorage(), null, new KeyUtil(), factory); var observer = new TracingObserver(); crud.AddObserver(observer); // Load non-existing bean Assert.Null(crud.Load("any", 123)); Assert.Empty(observer.TraceLog); var bean = crud.Dispense <Tracer>(); bean.Put("p1", "test"); var id = crud.Store(bean); observer.TraceLog = ""; bean = crud.Load <Tracer>(id); Assert.Equal("ad: bl: al:" + id, bean.TraceLog); Assert.Equal("ad: bl: al:" + id, observer.TraceLog); Assert.NotNull(bean["id"]); Assert.Equal(id, bean["id"]); Assert.Equal("test", bean["p1"]); }
public void Dispense_Hooks() { var crud = new BeanCrud(null, null, null); var observer = new TracingObserver(); crud.AddObserver(observer); var bean = crud.Dispense<Tracer>(); Assert.Equal("tracer", bean.GetKind()); Assert.Equal("ad:", bean.TraceLog); Assert.Equal("ad:", observer.TraceLog); Assert.Same(bean, observer.LastBean); }
public void Dispense_Hooks() { var crud = new BeanCrud(null, null, null); var observer = new TracingObserver(); crud.AddObserver(observer); var bean = crud.Dispense <Tracer>(); Assert.Equal("tracer", bean.GetKind()); Assert.Equal("ad:", bean.TraceLog); Assert.Equal("ad:", observer.TraceLog); Assert.Same(bean, observer.LastBean); }
public void Store() { var crud = new BeanCrud(new InMemoryStorage(), null, new KeyUtil()); var observer = new TracingObserver(); crud.AddObserver(observer); var bean = crud.Dispense <Tracer>(); var id = crud.Store(bean); Assert.Equal(0L, id); Assert.Equal(0L, bean["id"]); Assert.Equal("ad: bs: as:" + id, bean.TraceLog); Assert.Equal("ad: bs: as:" + id, observer.TraceLog); }
public void Dispense_Hooks() { IBeanFactory factory = new BeanFactory(); factory.Options.ValidateGetColumns = false; var crud = new BeanCrud(null, null, null, factory); var observer = new TracingObserver(); crud.AddObserver(observer); var bean = crud.Dispense <Tracer>(); Assert.Equal("tracer", bean.GetKind()); Assert.Equal("ad:", bean.TraceLog); Assert.Equal("ad:", observer.TraceLog); Assert.Same(bean, observer.LastBean); }
public void Store() { IBeanFactory factory = new BeanFactory(); factory.Options.ValidateGetColumns = false; var crud = new BeanCrud(new InMemoryStorage(), null, new KeyUtil(), factory); var observer = new TracingObserver(); crud.AddObserver(observer); var bean = crud.Dispense <Tracer>(); var id = crud.Store(bean); Assert.Equal(0L, id); Assert.Equal(0L, bean["id"]); Assert.Equal("ad: bs: as:" + id, bean.TraceLog); Assert.Equal("ad: bs: as:" + id, observer.TraceLog); }
public void Load() { var crud = new BeanCrud(new InMemoryStorage(), null, new KeyUtil()); var observer = new TracingObserver(); crud.AddObserver(observer); // Load non-existing bean Assert.Null(crud.Load("any", 123)); Assert.Empty(observer.TraceLog); var bean = crud.Dispense<Tracer>(); bean.Put("p1", "test"); var id = crud.Store(bean); observer.TraceLog = ""; bean = crud.Load<Tracer>(id); Assert.Equal("ad: bl: al:" + id, bean.TraceLog); Assert.Equal("ad: bl: al:" + id, observer.TraceLog); Assert.NotNull(bean["id"]); Assert.Equal(id, bean["id"]); Assert.Equal("test", bean["p1"]); }
public void Trash() { var crud = new BeanCrud(new InMemoryStorage(), null, new KeyUtil()); var observer = new TracingObserver(); crud.AddObserver(observer); var bean = crud.Dispense <Tracer>(); observer.TraceLog = bean.TraceLog = ""; crud.Trash(bean); Assert.Empty(bean.TraceLog); Assert.Empty(observer.TraceLog); var id = crud.Store(bean); observer.TraceLog = bean.TraceLog = ""; crud.Trash(bean); Assert.Equal("bt:" + id + " at:" + id, bean.TraceLog); Assert.Equal("bt:" + id + " at:" + id, observer.TraceLog); Assert.Equal(id, bean["id"]); Assert.Null(crud.Load <Tracer>(id)); }
public void Trash() { var crud = new BeanCrud(new InMemoryStorage(), null, new KeyUtil()); var observer = new TracingObserver(); crud.AddObserver(observer); var bean = crud.Dispense<Tracer>(); observer.TraceLog = bean.TraceLog = ""; crud.Trash(bean); Assert.Empty(bean.TraceLog); Assert.Empty(observer.TraceLog); var id = crud.Store(bean); observer.TraceLog = bean.TraceLog = ""; crud.Trash(bean); Assert.Equal("bt:" + id + " at:" + id, bean.TraceLog); Assert.Equal("bt:" + id + " at:" + id, observer.TraceLog); Assert.Equal(id, bean["id"]); Assert.Null(crud.Load<Tracer>(id)); }
public void Store() { var crud = new BeanCrud(new InMemoryStorage(), null, new KeyUtil()); var observer = new TracingObserver(); crud.AddObserver(observer); var bean = crud.Dispense<Tracer>(); var id = crud.Store(bean); Assert.Equal(0L, id); Assert.Equal(0L, bean["id"]); Assert.Equal("ad: bs: as:" + id, bean.TraceLog); Assert.Equal("ad: bs: as:" + id, observer.TraceLog); }