Ejemplo n.º 1
0
        public void UpdateWithSimple()
        {
            Location location = Util.CreateLocation("湖北省");

            var cmd = new UpdateLocation(location.Id)
            {
                Name       = "武汉",
                SortNumber = 1,
                MarkedCode = "wuhan"
            };

            cmd.Execute();
            Util.AssertLocation(location.Id, (name: "武汉", markedCode: "wuhan", sortNumber: 1, parentId: 0, childCount: 0));
        }
Ejemplo n.º 2
0
        public void UpdateWithExistName()
        {
            Location chinese = Util.CreateLocation("中国");
            Location hubei   = Util.CreateLocation("湖北省", chinese.Id);
            Location wuhan   = Util.CreateLocation("武汉", hubei.Id);
            Location xiaogan = Util.CreateLocation("孝感", hubei.Id);
            Location hunan   = Util.CreateLocation("湖南省", chinese.Id);
            {
                var cmd = new UpdateLocation(hubei.Id)

                {
                    Name       = "中国",
                    SortNumber = 0,
                    MarkedCode = "chinese",
                };
                cmd.Execute();
                Util.AssertLocation(hubei.Id, (name: "中国", markedCode: "chinese", sortNumber: 0, parentId: chinese.Id, childCount: 2));
            }
            {
                var cmd = new UpdateLocation(hubei.Id)

                {
                    Name       = "武汉",
                    SortNumber = 0,
                    MarkedCode = "wuhan",
                };
                cmd.Execute();
                Util.AssertLocation(hubei.Id, (name: "武汉", markedCode: "wuhan", sortNumber: 0, parentId: chinese.Id, childCount: 2));
            }
            {
                var cmd = new UpdateLocation(hubei.Id)
                {
                    Name       = "湖南省",
                    SortNumber = 0,
                    MarkedCode = "hunan",
                };
                cmd.Execute();
                Util.AssertLocation(hubei.Id, (name: "湖南省", markedCode: "hunan", sortNumber: 0, parentId: chinese.Id, childCount: 2));
            }
            {
                var cmd = new UpdateLocation(hunan.Id)
                {
                    Name       = "孝感",
                    SortNumber = 2,
                    MarkedCode = "xiaogan",
                };
                cmd.Execute();
                Util.AssertLocation(hunan.Id, (name: "孝感", markedCode: "xiaogan", sortNumber: 2, parentId: chinese.Id, childCount: 0));
            }
        }
Ejemplo n.º 3
0
        public void UpdateWithParentAndChild()
        {
            Location chinese = Util.CreateLocation("中国");
            Location hubei   = Util.CreateLocation("湖北省", chinese.Id);
            Location wuhan   = Util.CreateLocation("武汉", hubei.Id);
            Location xiaogan = Util.CreateLocation("孝感", hubei.Id);
            Location hunan   = Util.CreateLocation("湖南省", chinese.Id);

            {
                var cmd = new UpdateLocation(hunan.Id)
                {
                    Name       = "长沙",
                    SortNumber = 1,
                    MarkedCode = "changsha",
                };
                cmd.Execute();
                Util.AssertLocation(hunan.Id, (name: "长沙", markedCode: "changsha", sortNumber: 1, parentId: chinese.Id, childCount: 0));
            }
            {
                var cmd = new UpdateLocation(hubei.Id)
                {
                    Name       = "鄂州",
                    SortNumber = 3,
                    MarkedCode = "ezhou",
                };
                cmd.Execute();
                Util.AssertLocation(hubei.Id, (name: "鄂州", markedCode: "ezhou", sortNumber: 3, parentId: chinese.Id, childCount: 2));
            }
            {
                var cmd = new UpdateLocation(hubei.Id)
                {
                    Name       = "天心区",
                    SortNumber = 0,
                    MarkedCode = "tianxinqu",
                };
                cmd.Execute();
                Util.AssertLocation(hubei.Id, (name: "天心区", markedCode: "tianxinqu", sortNumber: 0, parentId: chinese.Id, childCount: 2));
            }
        }