Exemplo n.º 1
0
        public void Add_Duplicate_Model()
        {
            var context = new MockContext();
            var store = new VehicleStore(context);

            var model = new Model()
            {
                Id = 2,
                Make = _make,
                Name = "Klaker"
            };

            context.Models.Add(model);
            model.Id = 3;

            store.AddModel(model);
        }
Exemplo n.º 2
0
        public void Duplicate_Model_Different_Make()
        {
            var context = new MockContext();
            var store = new VehicleStore(context);

            var model = new Model()
            {
                Id = 2,
                Make = _make,
                Name = "Klaker"
            };

            context.Models.Add(model);
            model = new Model()
            {
                Id = 3,
                Name = "Klaker",
                Make = new Make
                {
                    Id = 3,
                    Name = "Suzoooki"
                }
            };

            store.AddModel(model);

            model = context.Models.Last();
            Assert.AreEqual(3, model.Id);
            Assert.AreEqual("Klaker", model.Name);

            var make = model.Make;
            Assert.AreEqual(3, make.Id);
            Assert.AreEqual("Suzoooki", make.Name);
            Assert.AreEqual(1, context.SaveChangesCalls);
        }
Exemplo n.º 3
0
        public void Add_Model()
        {
            var context = new MockContext();
            var store = new VehicleStore(context);

            store.AddModel(new Model
            {
                Id = 2,
                Make = _make,
                Name = "Klaker"
            });

            var model = context.Models.First();
            Assert.AreEqual(2, model.Id);
            Assert.AreEqual(_make, model.Make);
            Assert.AreEqual("Klaker", model.Name);
            Assert.AreEqual(1, context.SaveChangesCalls);
        }