Exemple #1
0
        public void RefLoopTest()
        {
            var obj = new RefLoop();

            obj.Loop = obj;

            var maskedResult = ControllerExtension.Mask(null, obj, "NoPatternName");
        }
Exemple #2
0
        public void ByPackageType()
        {
            var maskedResult = ControllerExtension.Mask(null, Category_PackageType.GetCategories());

            foreach (var category in maskedResult)
            {
                Assert.Null(category.Children);
            }
        }
Exemple #3
0
        public void ByPatternName()
        {
            var maskedResult = ControllerExtension.Mask(null, Category_PatternName.GetCategories(), "MaskName");

            foreach (var category in maskedResult)
            {
                Assert.Null(category.Children);
            }
        }
Exemple #4
0
        public void EFTest()
        {
            var options = new DbContextOptionsBuilder <TestContext>()
                          .UseInMemoryDatabase(databaseName: "Find_searches_url")
                          .Options;

            using (var context = new TestContext(options)) {
                Category_EF category_EF1;
                context.Categories.Add(category_EF1 = new Category_EF {
                    Name = "A"
                });

                category_EF1.Children.Add(new Category_EF()
                {
                    Name = "A-1"
                });

                context.Categories.Add(new Category_EF {
                    Name = "B"
                });
                context.Categories.Add(new Category_EF {
                    Name = "C"
                });
                context.SaveChanges();
            }

            using (var context = new TestContext(options)) {
                var data = ControllerExtension.Mask(
                    null,
                    context.Categories.Where(x => 1 == 1),
                    "Mask");

                foreach (var category in data)
                {
                    Assert.NotNull(category.Name);
                    Assert.Null(category.Children);
                    Assert.Null(category.Parent);
                }

                //嘗試儲存變更,確認是否deepclone有作用
                context.SaveChanges();
            }

            using (var context = new TestContext(options)) {
                Assert.True(context.Categories.Any(x => x.Children.Count > 0));
            }


            var data2 = new MyPaging <User>(User.GetList(), 0, 10);

            foreach (var item in data2.Result)
            {
                Assert.Null(item.Password);
            }
        }