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 JsonIgnore_Should_Ok()
        {
            var fooVo = new FooVo();
            var json  = JsonConvert.SerializeObject(fooVo, Formatting.Indented).Log();

            json.Contains(nameof(fooVo.MsIgnored), StringComparison.OrdinalIgnoreCase).ShouldFalse();
            json.Contains(nameof(fooVo.NewtonIgnored), StringComparison.OrdinalIgnoreCase).ShouldFalse();
        }
        public void Default_Should_Include_ALL()
        {
            var fooVo = new FooVo();

            fooVo.Id   = "001";
            fooVo.Name = "fooVo";
            fooVo.Set("check1", "check1Invoked");
            fooVo.Set("check2", "check2Invoked");

            var jsonFilter = fooVo.GetJson(true);

            jsonFilter.Contains("check1Invoked", StringComparison.OrdinalIgnoreCase).ShouldTrue();
            jsonFilter.Contains("check2Invoked", StringComparison.OrdinalIgnoreCase).ShouldTrue();
        }
        public void ApplyProviders_NoProviders_Should_Ok()
        {
            var fooVo = new FooVo();

            fooVo.Id   = "001";
            fooVo.Name = "fooVo";
            var fooVoContext = ExpandoPropertyContext <FooVo> .Create(fooVo);

            AsyncHelper.RunSync(async() => { await fooVoContext.ApplyProviders(null); });
            var jsonFilter = fooVo.GetJson(true);

            jsonFilter.Contains("provider1Invoked", StringComparison.OrdinalIgnoreCase).ShouldFalse();
            jsonFilter.Contains("provider2Invoked", StringComparison.OrdinalIgnoreCase).ShouldFalse();
        }
        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();
        }
        public void Merge_Should_Ok()
        {
            var fooVo = new FooVo();

            var fooEntity = new FooEntity();

            fooEntity.Id   = "entity id";
            fooEntity.Name = "entity name";
            fooEntity.Desc = "entity desc";
            fooVo.Merge(fooEntity);

            //fooVo.IncludeAll();

            var json = JsonConvert.SerializeObject(fooVo, Formatting.Indented).Log();

            json.Contains("entity id", StringComparison.OrdinalIgnoreCase).ShouldTrue();
            json.Contains("entity name", StringComparison.OrdinalIgnoreCase).ShouldTrue();
            json.Contains("entity desc", StringComparison.OrdinalIgnoreCase).ShouldTrue();
        }
        public void ApplyProviders_HasProviders_Should_Ok()
        {
            var fooVo = new FooVo();

            fooVo.Id   = "001";
            fooVo.Name = "fooVo";

            //fooVo.IncludeAll();

            var fooVoContext = ExpandoPropertyContext <FooVo> .Create(fooVo);

            AsyncHelper.RunSync(async() => { await fooVoContext.ApplyProviders(new List <IExpandoPropertyProvider <FooVo> > {
                    new MockProvider1(), new MockProvider2()
                }); });

            var jsonFilter = fooVo.GetJson(true);

            jsonFilter.Contains("provider1Invoked", StringComparison.OrdinalIgnoreCase).ShouldTrue();
            jsonFilter.Contains("provider2Invoked", StringComparison.OrdinalIgnoreCase).ShouldTrue();
        }