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 PostProduct_ShouldFail_WhenModel()
        {
            var controller = new MachinesController(new TestMachineContextGood());
            var item       = new Machine
            {
                Type        = "DemoType",
                Mark        = "DemoMark",
                Model       = "DemoModel",
                Year        = 2000,
                StateNumber = "DemoNum",
                VIN         = "DemoVIN",
                IdUsers     = 1
            };

            var result = controller.PostMachine(item).Result as CreatedAtRouteNegotiatedContentResult <Machine>;

            Assert.IsNotNull(result);
        }
        public void PostProduct_ShouldReturnSameProduct()
        {
            var controller = new MachinesController(new TestMachineContextGood());

            var item = GetDemoProduct();

            var result =
                controller.PostMachine(item).Result as CreatedAtRouteNegotiatedContentResult <Machine>;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.RouteName, "DefaultApi");
            Assert.AreEqual(result.RouteValues["id"], result.Content.Id);
            Assert.AreEqual(result.Content.Type, item.Type);
            Assert.AreEqual(result.Content.Mark, item.Mark);
            Assert.AreEqual(result.Content.Model, item.Model);
            Assert.AreEqual(result.Content.Year, item.Year);
            Assert.AreEqual(result.Content.StateNumber, item.StateNumber);
            Assert.AreEqual(result.Content.VIN, item.VIN);
            Assert.AreEqual(result.Content.IdUsers, item.IdUsers);
        }