public void StudentCreateTest()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);

            ViewResult result = controller.Index() as ViewResult;

            Assert.IsNotNull(result);
        }
        public void IspitDetailsCorrectIDTest()
        {
            //Test Details when id that exist in db is passed
            var db = new TestStudentIspitiContext();
            db.Initialize();
            IspitController controller = new IspitController(db);

            var result = controller.Details(2) as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model,typeof(Ispit));
        }
        public void IspitDeleteCorrectID()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            IspitController controller = new IspitController(db);
            int i = 2;

            var result = controller.Delete(i) as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(Ispit));
        }
        public void StudentDeleteCorrectID()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);
            string i = "07_001";

            var result = controller.Delete(i) as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(Student));
        }
        public void IspitDeleteNotCorrectID()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            IspitController controller = new IspitController(db);
            int i = 100;

            var result = controller.Delete(i);

            Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult));
            var httpResult = result as HttpNotFoundResult;
            Assert.AreEqual(404, httpResult.StatusCode);
        }
        public void IspitDeleteConfirmedTest()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            IspitController controller = new IspitController(db);
            int i = 20;

            var result = controller.DeleteConfirmed(i);

            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
            var tempresult = result as RedirectToRouteResult;
            Assert.AreEqual("Index", tempresult.RouteValues["action"]);
        }
        public void StudentCreateTestValidStudent()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);
            Student temp = new Student { BI = "07_020", Ime = "Jovan", Prezime = "Jovanovic", Adresa = "Dimitrija Tucovica 24", Grad = "Beograd" };

            var result = controller.Create(temp);// as RedirectToRouteResult;

            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
            var tempresult = result as RedirectToRouteResult;
            Assert.AreEqual("Index", tempresult.RouteValues["action"]);
        }
        public void IspitDeleteNullTest()
        {
            /*Test Delete when null is passed*/
            var db = new TestStudentIspitiContext();
            db.Initialize();
            IspitController controller = new IspitController(db);
            int? i = null;

            var result = controller.Delete(i);

            Assert.IsInstanceOfType(result, typeof(System.Web.Mvc.HttpStatusCodeResult));
            var httpResult = result as HttpStatusCodeResult;
            Assert.AreEqual(400, httpResult.StatusCode);
        }
        public void IspitDetailsNotCorrectIDTest()
        {
            //Test Details when id that does not exist in db is passed
            var db = new TestStudentIspitiContext();
            db.Initialize();
            IspitController controller = new IspitController(db);

            var result = controller.Details(100);

            Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult));
            var httpResult = result as HttpNotFoundResult;
            Assert.AreEqual(404, httpResult.StatusCode);
        }
        public void IspitIndexTest()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            IspitController controller = new IspitController(db);

            ViewResult result = controller.Index() as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(List<Ispit>));
        }
        public void StudentEditNullTest()
        {
            /*Test Edit when null is passed*/
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);
            string i = null;

            var result = controller.Edit(i);

            Assert.IsInstanceOfType(result, typeof(System.Web.Mvc.HttpStatusCodeResult));
            var httpResult = result as HttpStatusCodeResult;
            Assert.AreEqual(400, httpResult.StatusCode);
        }
        public void StudentEditNotCorrectID()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);
            string i = "99_999";

            var result = controller.Edit(i);

            Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult));
            var httpResult = result as HttpNotFoundResult;
            Assert.AreEqual(404, httpResult.StatusCode);
        }
        public void StudentdoesBIExistTestIDNotExist()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);
            string bi = "99_999";

            var result = controller.doesBIExist(bi);

            Assert.IsInstanceOfType(result, typeof(JsonResult));
            Assert.AreEqual(result.Data, true);
        }
        public void StudentDetailsNullTest()
        {
            /*Test Details when null is passed*/
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);

            var result = controller.Details(null);

            Assert.IsInstanceOfType(result, typeof(HttpStatusCodeResult));
            var httpResult = result as HttpStatusCodeResult;
            Assert.AreEqual(400, httpResult.StatusCode);
        }