예제 #1
0
        public void CarBrandDoorTest3()
        {
            CarBrand  brand = CreateCarBrand(100);
            BrandDoor door  = new BrandDoor(1)
            {
                Name = "BrandDoor", OrderIndex = 10
            };

            brand.OneDoor   = door;
            brand.OtherDoor = door;

            AddCarBrand(brand);

            CheckDoorAssociatedCount(door.Id, 2);

            brand.OneDoor = BrandDoor.Empty;
            UpdateCarBrand(brand);

            CheckDoorAssociatedCount(door.Id, 1);

            CheckExist(door.Id, true);

            brand.OtherDoor = BrandDoor.Empty;
            UpdateCarBrand(brand);

            CheckExist(door.Id, false);
        }
예제 #2
0
        public WholeColor(string name, int colorNum, bool isPainted, CarBrand brand = null, CarAccessory accessory = null)
        {
            this.Name      = name;
            this.ColorNum  = colorNum;
            this.IsPainted = isPainted;

            if (brand == null)
            {
                this.Brand = CarBrand.Empty;
            }
            else
            {
                this.Brand = brand;
            }

            if (accessory == null)
            {
                this.Accessory = CarAccessory.Empty;
            }
            else
            {
                this.Accessory = accessory;
            }


            this.OnConstructed();
        }
예제 #3
0
        public void CarBrandDoorTest11()
        {
            CarBrand  brand = CreateCarBrand(100);
            BrandDoor door  = new BrandDoor(1)
            {
                Name = "BrandDoor", OrderIndex = 10
            };

            brand.AddMyDoor(door);
            brand.AddOtherDoor(door);

            AddCarBrand(brand);

            CheckDoorAssociatedCount(door.Id, 2);

            brand.AddOtherDoor(door);
            UpdateCarBrand(brand);

            CheckDoorAssociatedCount(door.Id, 3);

            brand.RemoveOtherDoor(door);
            UpdateCarBrand(brand);
            CheckDoorAssociatedCount(door.Id, 2);

            CheckExist(door.Id, true);
        }
예제 #4
0
        public void CarBrandDoorTest13()
        {
            CarBrand  brand = CreateCarBrand(100);
            BrandDoor door  = new BrandDoor(1)
            {
                Name = "BrandDoor", OrderIndex = 10
            };

            brand.OneDoor = door;
            AddCarBrand(brand);

            CheckDoorAssociatedCount(door.Id, 1);

            brand.AddOtherDoor(door);
            UpdateCarBrand(brand);

            CheckDoorAssociatedCount(door.Id, 2);

            brand.AddMyDoor(door);
            UpdateCarBrand(brand);

            CheckDoorAssociatedCount(door.Id, 3);

            brand.OtherDoor = door;
            UpdateCarBrand(brand);

            CheckDoorAssociatedCount(door.Id, 4);
        }
예제 #5
0
        public void CarBrandTest13()
        {
            CarBrand       brand = CreateCarBrand(100);
            BrandAccessory acc   = new BrandAccessory("CarBrand配饰", 10, new DateTime(2017, 6, 1));

            brand.BrandAccessory = acc;
            AddCarBrand(brand);

            CheckAccessoryAssociatedCount(acc.Id, 1);

            brand.AddYouAccessory(acc);
            UpdateCarBrand(brand);

            CheckAccessoryAssociatedCount(acc.Id, 2);

            brand.AddMyAccessory(acc);
            UpdateCarBrand(brand);

            CheckAccessoryAssociatedCount(acc.Id, 3);

            brand.OtherAccessory = acc;
            UpdateCarBrand(brand);

            CheckAccessoryAssociatedCount(acc.Id, 4);
        }
예제 #6
0
        private CarBrand CreateCarBrand(int id)
        {
            CarBrand brand = new CarBrand(id);

            brand.Name       = "著名品牌";
            brand.CreateDate = new DateTime(2016, 5, 1);

            return(brand);
        }
예제 #7
0
        private void UpdateCarBrand(CarBrand brand)
        {
            this.BeginTransaction();

            var repository = Repository.Create <ICarBrandRepository>();

            repository.Update(brand);

            this.Commit();
        }
예제 #8
0
        public void CarBrandTest1()
        {
            CarBrand       brand = CreateCarBrand(100);
            BrandAccessory acc   = new BrandAccessory("CarBrand配饰", 10, new DateTime(2017, 6, 1));

            brand.BrandAccessory = acc;
            AddCarBrand(brand);

            CheckAccessoryAssociatedCount(acc.Id, 1);

            brand.BrandAccessory = BrandAccessory.Empty;
            UpdateCarBrand(brand);

            CheckExist(acc.Id, false);
        }
예제 #9
0
        public void CarBrandTest6()
        {
            CarBrand       brand = CreateCarBrand(100);
            BrandAccessory acc   = new BrandAccessory("CarBrand配饰", 10, new DateTime(2017, 6, 1));

            brand.AddMyAccessory(acc);

            AddCarBrand(brand);

            CheckAccessoryAssociatedCount(acc.Id, 1);

            brand.RemoveMyAccessory(acc);
            UpdateCarBrand(brand);

            CheckExist(acc.Id, false);
        }
예제 #10
0
        public void CarBrandTest15()
        {
            BrandAccessory acc = new BrandAccessory("CarBrand1配饰", 10, new DateTime(2017, 6, 1));

            CarBrand brand1 = CreateCarBrand(100);

            brand1.BrandAccessory = acc;
            AddCarBrand(brand1);

            CheckAccessoryAssociatedCount(acc.Id, 1);

            CarBrand brand2 = CreateCarBrand(101);

            brand2.BrandAccessory = acc;
            AddCarBrand(brand2);

            //CheckAccessoryAssociatedCount(acc.Id, 2);
        }
예제 #11
0
        public void CarBrandTest5()
        {
            CarBrand       brand = CreateCarBrand(100);
            BrandAccessory acc   = new BrandAccessory("CarBrand配饰", 10, new DateTime(2017, 6, 1));

            brand.BrandAccessory = acc;

            AddCarBrand(brand);

            CheckAccessoryAssociatedCount(acc.Id, 1);

            brand.OtherAccessory = acc;
            UpdateCarBrand(brand);

            CheckAccessoryAssociatedCount(acc.Id, 2);

            CheckExist(acc.Id, true);
        }