public void PutProduct_ShouldFail_WhenModel2()
        {
            var context = new TestMachineContextBad();

            context.Machines.Add(GetDemoProduct());

            var controller = new MachinesController(context);

            Machine item = new Machine
            {
                Id          = 1,
                Type        = "DemoType",
                Mark        = "DemoMark",
                Model       = "DemoModel",
                Year        = 2000,
                StateNumber = "DemoNum",
                VIN         = "DemoVIN",
                IdUsers     = 1
            };

            controller.Configuration = new HttpConfiguration();
            controller.Validate(item);
            var result = controller.PutMachine(1, item).Result as StatusCodeResult;

            Assert.AreEqual(HttpStatusCode.InternalServerError, result.StatusCode);
        }
        public void test_validation()
        {
            var context = new TestMachineContextGood();

            context.Machines.Add(GetDemoProduct());
            Machine item = new Machine
            {
                Id          = 1,
                Type        = "DemoType",
                Mark        = string.Empty,
                Model       = "DemoModel",
                Year        = 2000,
                StateNumber = "DemoNum",
                VIN         = "DemoVIN",
                IdUsers     = 1
            };
            var controller = new MachinesController();

            controller.Configuration = new HttpConfiguration();

            controller.Validate(item);
            var result = controller.PostMachine(item).Result;

            Assert.IsInstanceOfType(result, typeof(InvalidModelStateResult));
            Assert.AreEqual(1, context.Machines.Count());
        }
        public void PutProduct_ShouldFail_WhenModel()
        {
            var context = new TestMachineContextGood();

            context.Machines.Add(GetDemoProduct());

            var controller = new MachinesController(context);

            Machine item = new Machine
            {
                Type        = "DemoType",
                Mark        = null,
                Model       = null,
                Year        = 1990,
                StateNumber = "DemoNum",
                VIN         = null,
                IdUsers     = 8
            };

            controller.Configuration = new HttpConfiguration();
            controller.Validate(item);
            var result = controller.PutMachine(item.Id, item).Result;

            Assert.IsInstanceOfType(result, typeof(InvalidModelStateResult));
        }