public void Set_Delay_Should_Ok() { var fooVo = new FooVo(); fooVo.Id = "001"; fooVo.Name = "fooVo"; fooVo.Set("check1", () => { fooVo.Name += "+check1"; return("foo"); }); fooVo.Set("check2", () => { fooVo.Name += "+check2"; return("foo"); }); fooVo.AddPropertyFilter(ExpandoPropertyFilterFactory.CreateExcludeFilter("check1")); var jsonFilter = fooVo.GetJson(true); jsonFilter.Contains("+check1", StringComparison.OrdinalIgnoreCase).ShouldFalse(); jsonFilter.Contains("+check2", StringComparison.OrdinalIgnoreCase).ShouldTrue(); fooVo.Name.ShouldEqual("fooVo+check2"); }
public void Set_Lazy_Should_Ok() { var fooVo = new FooVo(); fooVo.Id = "001"; fooVo.Name = "fooVo"; fooVo.Set("check1", new Lazy <string>(() => "check1Invoked")); fooVo.Set("check2", new Lazy <string>(() => "check2Invoked")); fooVo.AddPropertyFilter(ExpandoPropertyFilterFactory.CreateExcludeFilter("check1")); var jsonFilter = fooVo.GetJson(true); jsonFilter.Contains("check1Invoked", StringComparison.OrdinalIgnoreCase).ShouldFalse(); jsonFilter.Contains("check2Invoked", StringComparison.OrdinalIgnoreCase).ShouldTrue(); }