Esempio n. 1
0
 public AnimalColor(string name, int colorNum, bool isPainted, AnimalCategory category, AnimalAccessory accessory)
 {
     this.Name      = name;
     this.ColorNum  = colorNum;
     this.IsPainted = isPainted;
     this.Category  = category;
     this.Accessory = accessory;
     this.OnConstructed();
 }
Esempio n. 2
0
        private void DeleteAnimalCategory(AnimalCategory category)
        {
            this.BeginTransaction();

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

            repository.Delete(category);

            this.Commit();
        }
Esempio n. 3
0
        private void UpdateAnimalCategory(int id, string name, DateTime date)
        {
            this.BeginTransaction();

            AnimalCategory mycategory = GetAnimalCategory(id, QueryLevel.Single);

            mycategory.Name       = name;
            mycategory.CreateDate = date;

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

            repository.Update(mycategory);

            this.Commit();
        }
Esempio n. 4
0
        private AnimalCategory InsertAnimalCategory(int id, string name, DateTime date)
        {
            this.BeginTransaction();

            AnimalCategory category = new AnimalCategory(id);

            category.Name       = name;
            category.CreateDate = date;

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

            repository.Add(category);

            this.Commit();

            return(category);
        }
Esempio n. 5
0
        public void AnimalComplexTest2()
        {
            var animal = this.Fixture.Get <Animal>() as Animal;

            CheckAnimalVersion(animal.Id, 1);

            Animal aniMemmory = GetAnimal(animal.Id);

            Assert.AreEqual(aniMemmory.Category.Name, "爬行类");

            // 修改
            AnimalCategory category = InsertAnimalCategory(2, "灵长类", new DateTime(2017, 6, 3));

            animal.Category = category;

            UpdateAnimal(animal);

            aniMemmory = GetAnimal(animal.Id);
            Assert.AreEqual(aniMemmory.Category.Name, "灵长类");

            CheckAnimalVersion(animal.Id, 2);
        }
Esempio n. 6
0
        public void AnimalComplexTest6()
        {
            var animal = this.Fixture.Get <Animal>() as Animal;

            CheckAnimalVersion(animal.Id, 1);

            Animal aniMemmory = GetAnimal(animal.Id);

            Assert.AreEqual(aniMemmory.GetMainWheel().Category.Name, "main Wheel动物类");

            // 修改
            AnimalCategory category = InsertAnimalCategory(7, "main Wheel灵长类", new DateTime(2017, 6, 6));

            animal.GetMainWheel().Category = category;

            UpdateAnimal(animal);

            aniMemmory = GetAnimal(animal.Id);
            Assert.AreEqual(aniMemmory.GetMainWheel().Category.Name, "main Wheel灵长类");

            CheckAnimalVersion(animal.Id, 2);
        }
Esempio n. 7
0
        public void AnimalComplexTest4()
        {
            var animal = this.Fixture.Get <Animal>() as Animal;

            CheckAnimalVersion(animal.Id, 1);

            Animal aniMemmory = GetAnimal(animal.Id);

            Assert.AreEqual(aniMemmory.AllColor.Category.Name, "AllColor动物类");

            // 修改
            AnimalCategory category = InsertAnimalCategory(6, "AllColor灵长类", new DateTime(2017, 6, 6));

            animal.AllColor = new AnimalColor("AllColor", 6, true, category, AnimalAccessory.Empty);

            UpdateAnimal(animal);

            aniMemmory = GetAnimal(animal.Id);
            Assert.AreEqual(aniMemmory.AllColor.Category.Name, "AllColor灵长类");

            CheckAnimalVersion(animal.Id, 2);
        }
Esempio n. 8
0
        public void AnimalComplexTest3()
        {
            var animal = this.Fixture.Get <Animal>() as Animal;

            CheckAnimalVersion(animal.Id, 1);

            Animal aniMemmory = GetAnimal(animal.Id);

            Assert.AreEqual(aniMemmory.GetMyColors().ElementAt(0).Category.Name, "红色动物类");

            // 修改
            AnimalCategory category = animal.GetMyColors().ElementAt(0).Category;

            UpdateAnimalCategory(category.Id, "红色动物类修改", new DateTime(2017, 6, 3));

            UpdateAnimal(animal);

            aniMemmory = GetAnimal(animal.Id);
            Assert.AreEqual(aniMemmory.GetMyColors().ElementAt(0).Category.Name, "红色动物类修改");

            CheckAnimalVersion(animal.Id, 1);
            CheckAnimalCategoryVersion(category.Id, 2);
        }
Esempio n. 9
0
        public void AnimalComplexTest10()
        {
            var animal = this.Fixture.Get <Animal>() as Animal;

            CheckAnimalVersion(animal.Id, 1);

            Animal aniMemmory = GetAnimal(animal.Id);

            Assert.AreEqual(aniMemmory.GetMainBreak().Category.Name, "MyAnimalBreak动物类");

            // 修改
            AnimalCategory category = InsertAnimalCategory(8, "MyAnimalBreak灵长类", new DateTime(2017, 6, 9));

            animal.GetMainBreak().Category = category;

            UpdateAnimal(animal);

            aniMemmory = GetAnimal(animal.Id);
            Assert.AreEqual(aniMemmory.GetMainBreak().Category.Name, "MyAnimalBreak灵长类");

            CheckAnimalVersion(animal.Id, 2);
            CheckAnimalBreakVersion(aniMemmory.GetMainBreak().Id, 2);
        }
Esempio n. 10
0
        private Animal CreateAnimal()
        {
            AnimalCategory category = InsertAnimalCategory(1, "爬行类", new DateTime(2017, 6, 1));

            Animal animal = new Animal(Guid.NewGuid());

            animal.Category = category;
            animal.Name     = "一只动物";
            animal.LiveTime = new DateTime(2017, 6, 1);

            AnimalEye eye1 = new AnimalEye(1)
            {
                Description = "AllWheelDoorEye",
                CreateDate  = new DateTime(2017, 6, 1)
            };

            AnimalWheel allWheel = new AnimalWheel(40)
            {
                OrderIndex  = 1,
                Description = "the allWheel",
                TheColor    = new AnimalColor("主色", 5, true, AnimalCategory.Empty, AnimalAccessory.Empty),
                Category    = InsertAnimalCategory(90, "main Wheel动物类", new DateTime(2017, 6, 1)),
                Accessory   = new AnimalAccessory("allWheel配饰", 5, new DateTime(2017, 6, 11), AnimalDoor.Empty, AnimalEye.Empty),
                Door        = new AnimalDoor(2)
                {
                    Name = "AllWheelDoor"
                },
                Eye = eye1
            };

            animal.AllWheel = allWheel;

            AnimalCategory category0 = InsertAnimalCategory(10, "AllColor动物类", new DateTime(2017, 6, 1));

            AnimalDoor door = new AnimalDoor(3)
            {
                Name = "AllColor配饰Door"
            };

            animal.AllColor = new AnimalColor("颜色", 8, true, category0,
                                              new AnimalAccessory("AllColor配饰", 10, new DateTime(2017, 6, 10), door, AnimalEye.Empty));

            AnimalDoor door2 = new AnimalDoor(4)
            {
                Name = "AllAccessoryDoor"
            };

            AnimalEye eye2 = new AnimalEye(2)
            {
                Description = "AllAccessoryAnimalEye",
                CreateDate  = new DateTime(2017, 6, 1)
            };

            animal.AllAccessory = new AnimalAccessory("AllAccessory", 8, new DateTime(2017, 6, 10), door2, eye2);

            List <AnimalColor> colors = new List <AnimalColor>();

            AnimalCategory category1 = InsertAnimalCategory(11, "红色动物类", new DateTime(2017, 6, 1));
            AnimalCategory category2 = InsertAnimalCategory(12, "蓝色动物类", new DateTime(2017, 6, 1));

            colors.Add(new AnimalColor("红色", 6, true, category1, AnimalAccessory.Empty));
            colors.Add(new AnimalColor("蓝色", 7, true, category2, AnimalAccessory.Empty));

            animal.SetMyColors(colors);

            AnimalWheel mainWheel = new AnimalWheel(30)
            {
                OrderIndex  = 1,
                Description = "the main Wheel",
                TheColor    = new AnimalColor("主色", 5, true, AnimalCategory.Empty, AnimalAccessory.Empty),
                Category    = InsertAnimalCategory(20, "main Wheel动物类", new DateTime(2017, 6, 1)),
                Accessory   = new AnimalAccessory("MainWheel配饰", 5, new DateTime(2017, 6, 11), AnimalDoor.Empty, AnimalEye.Empty),
                Door        = new AnimalDoor(5)
                {
                    Name = "MainWheelDoor"
                }
            };

            animal.SetMainWheel(mainWheel);

            AnimalWheel wheel1 = new AnimalWheel(2)
            {
                OrderIndex  = 11,
                Description = "theAnimalWheel1",
                TheColor    = new AnimalColor("红色", 6, true, AnimalCategory.Empty, AnimalAccessory.Empty)
            };

            AnimalWheel wheel2 = new AnimalWheel(3)
            {
                OrderIndex  = 12,
                Description = "theAnimalWheel2",
                TheColor    = new AnimalColor("蓝色", 7, true, AnimalCategory.Empty, AnimalAccessory.Empty)
            };

            List <AnimalWheel> wheels = new List <AnimalWheel>();

            wheels.Add(wheel1);
            wheels.Add(wheel2);

            animal.SetWheels(wheels);

            AnimalBreak mainBreak = new AnimalBreak(1)
            {
                Description = "MyAnimalBreak",
                CreateDate  = new DateTime(2017, 6, 1),
                Category    = InsertAnimalCategory(30, "MyAnimalBreak动物类", new DateTime(2017, 6, 30)),
                Accessory   = new AnimalAccessory("MyAnimalBreak配饰", 6, new DateTime(2017, 6, 16), AnimalDoor.Empty, AnimalEye.Empty)
            };

            animal.SetMainBreak(mainBreak);

            AnimalEye eye3 = new AnimalEye(3)
            {
                Description = "AllAnimalBreakAnimalEye",
                CreateDate  = new DateTime(2017, 6, 1)
            };

            AnimalBreak allBreak = new AnimalBreak(50)
            {
                Description = "AllAnimalBreak",
                CreateDate  = new DateTime(2017, 6, 1),
                Category    = InsertAnimalCategory(40, "AllAnimalBreak动物类", new DateTime(2017, 6, 30)),
                Door        = new AnimalDoor(6)
                {
                    Name = "AllAnimalBreakDoor"
                },
                Eye = eye3
            };

            animal.AllBreak = allBreak;

            return(animal);
        }