Ejemplo n.º 1
0
        public void PostAndDeleteTest()
        {
            var options = new DbContextOptionsBuilder <PharmacyDBContext>()
                          .UseSqlServer("Server=localhost\\SQLEXPRESS;Database=PharmacyDB; Trusted_Connection=True;MultipleActiveResultSets=true")
                          .Options;

            var context = new PharmacyDBContext(options);
            EmployeesController controller = new EmployeesController(context);

            var TestEmployees = new Employees {
                FullName = "UnitTest3", Salary = System.Convert.ToDecimal(1111.22222), IdBranch = 1
            };
            var CallBack = (Employees)((CreatedAtActionResult)controller.PostEmployees(TestEmployees).Result.Result).Value;

            var result = controller.DeleteEmployees(CallBack.Id).Result.Value;

            Assert.Equal(CallBack, result);//Assert
        }