示例#1
0
        public void AnimalExtensionTest23()
        {
            var animal = this.Fixture.Get <Animal>() as Animal;

            CheckAnimalVersion(animal.Id, 1);

            Animal animalMemmory = GetAnimal(animal.Id);

            Assert.AreEqual(animalMemmory.GetBreaks().Count, 2);

            // 修改
            AnimalBreak breaker3 = new AnimalBreak(13)
            {
                Description = "AnimalBreak3",
                CreateDate  = new DateTime(2017, 6, 3)
            };

            animal.GetBreaks().Add(breaker3);
            var repository = Repository.Create <IAnimalRepository>();

            UpdateAnimal(animal);

            animalMemmory = GetAnimal(animal.Id);

            Assert.AreEqual(animalMemmory.GetBreaks().Count, 3);

            var animalNew = FindAnimal(animal.Id);

            CheckAnimalVersion(animal.Id, 2);
        }
示例#2
0
        public void AnimalExtensionTest24()
        {
            var animal = this.Fixture.Get <Animal>() as Animal;

            CheckAnimalVersion(animal.Id, 1);

            Animal animalMemmory = GetAnimal(animal.Id);

            Assert.AreEqual(animalMemmory.GetBreaks().Count, 2);

            // 修改
            AnimalBreak breaker3 = new AnimalBreak(13)
            {
                Description = "AnimalBreak3",
                CreateDate  = new DateTime(2017, 6, 3)
            };

            List <AnimalBreak> breaks = new List <AnimalBreak>();

            AddAnimalBreak(breaker3, breaks);

            animal.SetBreaks(breaks);

            UpdateAnimal(animal);

            animalMemmory = GetAnimal(animal.Id);

            Assert.AreEqual(animalMemmory.GetBreaks().Count, 1);
            Assert.AreEqual(animalMemmory.GetBreaks().ElementAt(0).Description, "AnimalBreak3");

            var animalNew = FindAnimal(animal.Id);

            CheckAnimalVersion(animal.Id, 2);
        }
示例#3
0
        public void AnimalInherited2Test18()
        {
            var goldenDog = this.Fixture.Get <GoldenDog>() as GoldenDog;

            CheckGoldenDogVersion(goldenDog.Id, 1);
            GoldenDog dogMemmory = GetGoldenDog(goldenDog.Id);

            Assert.AreEqual(dogMemmory.GoldenBreaks.Count(), 2);

            // 修改
            AnimalBreak breaker = new AnimalBreak(23)
            {
                Description = "goldenDogBreak3",
                CreateDate  = new DateTime(2017, 6, 3)
            };

            goldenDog.AddGoldenBreak(breaker);

            UpdateGoldenDog(goldenDog);

            dogMemmory = GetGoldenDog(goldenDog.Id);
            Assert.AreEqual(dogMemmory.GoldenBreaks.Count(), 3);

            CheckGoldenDogVersion(goldenDog.Id, 2);
        }
示例#4
0
        public void AnimalExtensionTest22()
        {
            var animal = this.Fixture.Get <Animal>() as Animal;

            CheckAnimalVersion(animal.Id, 1);

            Animal animalMemmory = GetAnimal(animal.Id);

            Assert.AreEqual(animalMemmory.GetBreaks().Count, 2);

            // 修改
            AnimalBreak myBreak = animal.GetBreaks().ElementAt(0);

            RemoveAnimalBreak(myBreak, animal.GetBreaks());

            UpdateAnimal(animal);

            animalMemmory = GetAnimal(animal.Id);

            Assert.AreEqual(animalMemmory.GetBreaks().Count, 1);

            var animalNew = FindAnimal(animal.Id);

            CheckAnimalVersion(animal.Id, 2);
        }
        public void AnimalInheritedTest10()
        {
            var dog = this.Fixture.Get <Dog>() as Dog;

            CheckDogVersion(dog.Id, 1);

            // 修改
            AnimalBreak mybreak = new AnimalBreak(2)
            {
                Description = "other MainBreak",
                CreateDate  = new DateTime(2017, 6, 10)
            };

            dog.SetMainBreak(mybreak);

            this.BeginTransaction();

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

            repository.Update(dog);

            this.Commit();

            Dog dogMemmory = GetDog(dog.Id);

            Assert.AreEqual(dogMemmory.GetMainBreak().Description, "other MainBreak");
            CheckDogVersion(dog.Id, 2);
        }
示例#6
0
        public void AnimalInherited2Test16()
        {
            var goldenDog = this.Fixture.Get <GoldenDog>() as GoldenDog;

            CheckGoldenDogVersion(goldenDog.Id, 1);
            GoldenDog dogMemmory = GetGoldenDog(goldenDog.Id);

            Assert.AreEqual(dogMemmory.GoldenBreaks.Count(), 2);

            // 修改
            AnimalBreak breaker = goldenDog.GoldenBreaks.ElementAt(0);

            breaker.Description = "modify goldenDogBreak1";

            UpdateGoldenDog(goldenDog);

            dogMemmory = GetGoldenDog(goldenDog.Id);

            CheckGoldenDogVersion(goldenDog.Id, 2);
        }
示例#7
0
        public void AnimalExtensionTest17()
        {
            var animal = this.Fixture.Get <Animal>() as Animal;

            CheckAnimalVersion(animal.Id, 1);

            var animalNew = FindAnimal(animal.Id);

            Assert.AreEqual(animalNew.MainBreakId, 1);

            // 修改
            AnimalBreak mybreak = new AnimalBreak(2)
            {
                Description = "other MainBreak",
                CreateDate  = new DateTime(2017, 6, 10)
            };

            animal.SetMainBreak(mybreak);

            this.BeginTransaction();

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

            repository.Update(animal);

            this.Commit();

            Animal animalMemmory = GetAnimal(animal.Id);

            Assert.AreEqual(animalMemmory.GetMainBreak().CreateDate.ToString(), new DateTime(2017, 6, 10).ToString());
            Assert.AreEqual(animalMemmory.GetMainBreak().Description, "other MainBreak");

            animalNew = FindAnimal(animal.Id);

            CheckAnimalVersion(animal.Id, 2);

            CheckAnimalBreakVersion(animal.GetMainBreak().Id, 1);
        }
示例#8
0
 private void RemoveAnimalBreak(AnimalBreak mybreak, DomainCollection <AnimalBreak> breaks)
 {
     breaks.Remove(mybreak);
 }
示例#9
0
 private void AddAnimalBreak(AnimalBreak mybreak, List <AnimalBreak> breaks)
 {
     breaks.Add(mybreak);
 }
示例#10
0
        private Animal CreateAnimal()
        {
            Animal animal = new Animal(Guid.NewGuid());

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

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

            colors.Add(new AnimalColor("红色", 6, true, AnimalCategory.Empty, AnimalAccessory.Empty));
            colors.Add(new AnimalColor("蓝色", 7, true, AnimalCategory.Empty, 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)
            };

            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)
            };

            animal.SetMainBreak(mainBreak);

            AnimalBreak breaker1 = new AnimalBreak(11)
            {
                Description = "AnimalBreak1",
                CreateDate  = new DateTime(2017, 6, 1)
            };

            AnimalBreak breaker2 = new AnimalBreak(12)
            {
                Description = "AnimalBreak2",
                CreateDate  = new DateTime(2017, 6, 2)
            };

            List <AnimalBreak> breaks = new List <AnimalBreak>();

            AddAnimalBreak(breaker1, breaks);
            AddAnimalBreak(breaker2, breaks);

            animal.SetBreaks(breaks);

            return(animal);
        }
示例#11
0
        private GoldenDog CreateGoldenDog()
        {
            GoldenDog goldenDog = new GoldenDog(Guid.NewGuid());

            goldenDog.LegCounts.Add(1);
            goldenDog.LegCounts.Add(2);

            goldenDog.LegColor = new AnimalColor("Leg颜色", 8, true, AnimalCategory.Empty, AnimalAccessory.Empty);

            List <AnimalColor> colors = new List <AnimalColor>()
            {
                new AnimalColor("蓝色", 8, true, AnimalCategory.Empty, AnimalAccessory.Empty),
                new AnimalColor("红色", 9, true, AnimalCategory.Empty, AnimalAccessory.Empty)
            };

            goldenDog.HeadColors = colors;

            goldenDog.GoldenWheel = new AnimalWheel(100)
            {
                OrderIndex  = 1,
                Description = "the GoldenWheel",
                TheColor    = new AnimalColor("Golden", 5, true, AnimalCategory.Empty, AnimalAccessory.Empty)
            };

            goldenDog.GoldenBreak = new AnimalBreak(50)
            {
                Description = "GoldenBreak",
                CreateDate  = new DateTime(2017, 6, 1)
            };

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

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

            goldenDog.AddGoldenWheel(wheel1);
            goldenDog.AddGoldenWheel(wheel2);

            AnimalBreak breaker1 = new AnimalBreak(21)
            {
                Description = "goldenDogBreak1",
                CreateDate  = new DateTime(2017, 6, 1)
            };

            AnimalBreak breaker2 = new AnimalBreak(22)
            {
                Description = "goldenDogBreak2",
                CreateDate  = new DateTime(2017, 6, 2)
            };

            goldenDog.AddGoldenBreak(breaker1);
            goldenDog.AddGoldenBreak(breaker2);

            FillDog(goldenDog);
            FillAnimal(goldenDog);

            return(goldenDog);
        }
示例#12
0
 public void AddGoldenBreak(AnimalBreak breaker)
 {
     _GoldenBreaks.Add(breaker);
 }
示例#13
0
 public static void SetMainBreak(this Animal animal, AnimalBreak Abreak)
 {
     animal.SetValue(MainBreakProperty, Abreak);
 }
示例#14
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);
        }