public void CarTest18()
        {
            var car = this.Fixture.Get <Car>() as Car;

            CheckCarDataVersion(car.Id, 1);

            Assert.AreEqual(car.Doors.Count(), 0);

            // 修改
            CarDoor door1 = new CarDoor(1)
            {
                Name       = "1号门",
                OrderIndex = 10,
                TheColor   = new WholeColor("绿色", 9, false)
            };

            CarDoor door2 = new CarDoor(2)
            {
                Name       = "2号门",
                OrderIndex = 10,
                TheColor   = new WholeColor("蓝色", 8, true)
            };

            car.AddCarDoor(door1);
            car.AddCarDoor(door2);

            UpdateCar(car);

            Car carMemmory = GetCar(car.Id);

            Assert.AreEqual(carMemmory.Doors.Count(), 2);
            Assert.AreEqual(carMemmory.Doors.ElementAt(1).Name, "2号门");
            Assert.AreEqual(carMemmory.Doors.ElementAt(1).TheColor.Name, "蓝色");

            var carNew = FindCar(car.Id);

            CheckCarDataVersion(car.Id, 2);

            car.Doors.ElementAt(0).Name = "Update 1号门";
            UpdateCar(car);

            Car carMemmory2 = GetCar(car.Id);

            Assert.AreEqual(carMemmory2.Doors.Count(), 2);
            Assert.AreEqual(carMemmory2.Doors.ElementAt(0).Name, "Update 1号门");
            Assert.AreEqual(carMemmory2.Doors.ElementAt(0).TheColor.Name, "绿色");

            carNew = FindCar(car.Id);

            CheckCarDataVersion(car.Id, 3);
        }
Example #2
0
 public void AddCarDoor(CarDoor door)
 {
     _Doors.Add(door);
 }