public void DeleteConfirmed() { var repMock = new Mock<IFakultetRepository<Prijavas>>(); Students s1 = new Students() { BI = "10011", Ime = "Pera", Prezime = "Peric", Adresa = "Ulica1", Grad = "Grad1" }; Ispits i1 = new Ispits() { IspitID = 1, Naziv = "Ispit1" }; Prijavas prijavas = new Prijavas() { BI = "10011", IspitID = 1, Ocena = 8, Students = s1, Ispits = i1 }; object[] con = { prijavas.BI, prijavas.IspitID }; repMock.Setup(x => x.GetEntityById(con)).Returns(prijavas); controller = new PrijavasController(repMock.Object); var result = controller.DeleteConfirmed(prijavas.BI, prijavas.IspitID + "") as RedirectToRouteResult; repMock.VerifyAll(); Assert.AreEqual("Index", result.RouteValues["Action"]); }
public void CreatePrijavaParam() { var repMock = new Mock<IFakultetRepository<Prijavas>>(); Students s1 = new Students() { BI = "10011", Ime = "Pera", Prezime = "Peric", Adresa = "Ulica1", Grad = "Grad1" }; Ispits i1 = new Ispits() { IspitID = 1, Naziv = "Ispit1" }; Prijavas prijavas = new Prijavas() { BI = "10011", IspitID = 1, Ocena = 8, Students = s1, Ispits = i1 }; repMock.Setup(x => x.InsertEntity(prijavas)); controller = new PrijavasController(repMock.Object); var result = controller.Create(prijavas) as RedirectToRouteResult; repMock.VerifyAll(); Assert.AreEqual("Index", result.RouteValues["Action"]); }
public void DeleteIdParam() { var repMock = new Mock<IFakultetRepository<Prijavas>>(); Students s1 = new Students() { BI = "10011", Ime = "Pera", Prezime = "Peric", Adresa = "Ulica1", Grad = "Grad1" }; Ispits i1 = new Ispits() { IspitID = 1, Naziv = "Ispit1" }; Prijavas prijavas = new Prijavas() { BI = "10011", IspitID = 1, Ocena = 8, Students = s1, Ispits = i1 }; object[] con = { prijavas.BI, prijavas.IspitID }; repMock.Setup(x => x.GetEntityById(con)).Returns(prijavas); controller = new PrijavasController(repMock.Object); var result = controller.Delete(prijavas.BI, prijavas.IspitID + "") as ViewResult; Prijavas p = result.ViewData.Model as Prijavas; repMock.VerifyAll(); Assert.AreEqual("Delete", result.ViewName); Assert.AreEqual("10011-1", p.BI+"-"+p.IspitID); }
public void EditPrijavasParam() { var repMockPri = new Mock<IFakultetRepository<Prijavas>>(); var repMockStud = new Mock<IFakultetRepository<Students>>(); var repMockIsp = new Mock<IFakultetRepository<Ispits>>(); Students s1 = new Students() { BI = "10011", Ime = "Pera", Prezime = "Peric", Adresa = "Ulica1", Grad = "Grad1" }; Students s2 = new Students() { BI = "20011", Ime = "Marko", Prezime = "Markovic", Adresa = "Ulica2", Grad = "Grad2" }; Ispits i1 = new Ispits() { IspitID = 1, Naziv = "Ispit1" }; Ispits i2 = new Ispits() { IspitID = 2, Naziv = "Ispit2" }; Prijavas prijavas = new Prijavas() { BI = "10011", IspitID = 1, Ocena = 8, Students = s1, Ispits = i1 }; repMockPri.Setup(x => x.UpdateEntity(prijavas)); controller = new PrijavasController(repMockPri.Object); controller.SetIspitsRepository(repMockIsp.Object); controller.SetStudentsRepository(repMockStud.Object); var result = controller.Edit(prijavas); var viewResult = result as ViewResult; var rtaResult = result as RedirectToRouteResult; repMockIsp.VerifyAll(); repMockPri.VerifyAll(); repMockStud.VerifyAll(); Assert.AreEqual("Index", rtaResult.RouteValues["Action"]); }
public void EditIdParam() { var repMockPri = new Mock<IFakultetRepository<Prijavas>>(); var repMockStud = new Mock<IFakultetRepository<Students>>(); var repMockIsp = new Mock<IFakultetRepository<Ispits>>(); Students s1 = new Students() { BI = "10011", Ime = "Pera", Prezime = "Peric", Adresa = "Ulica1", Grad = "Grad1" }; Students s2 = new Students() { BI = "20011", Ime = "Marko", Prezime = "Markovic", Adresa = "Ulica2", Grad = "Grad2" }; Ispits i1 = new Ispits() { IspitID = 1, Naziv = "Ispit1" }; Ispits i2 = new Ispits() { IspitID = 2, Naziv = "Ispit2" }; Prijavas prijavas = new Prijavas() { BI = "10011", IspitID = 1, Ocena = 8, Students = s1, Ispits = i1 }; var studentList = new List<Students>(); studentList.Add(s1); studentList.Add(s2); var ispitList = new List<Ispits>(); ispitList.Add(i1); ispitList.Add(i2); object[] con = { prijavas.BI, prijavas.IspitID }; repMockPri.Setup(x => x.GetEntityById(con)).Returns(prijavas); repMockStud.Setup(x => x.GetEntities()).Returns(studentList); repMockIsp.Setup(x => x.GetEntities()).Returns(ispitList); controller = new PrijavasController(repMockPri.Object); controller.SetIspitsRepository(repMockIsp.Object); controller.SetStudentsRepository(repMockStud.Object); var result = controller.Edit(prijavas.BI, prijavas.IspitID + "") as ViewResult; var sList = result.ViewBag.BI as SelectList; var iList = result.ViewBag.IspitID as SelectList; repMockIsp.VerifyAll(); repMockPri.VerifyAll(); repMockStud.VerifyAll(); Assert.AreEqual("Edit", result.ViewName); Assert.AreEqual(sList.ElementAt(0).Value, "10011"); Assert.AreEqual(sList.ElementAt(1).Value, "20011"); Assert.AreEqual(iList.ElementAt(0).Value, 1+""); Assert.AreEqual(iList.ElementAt(1).Value, 2+""); }