public void VindCursusLijstPerWeekFaalend() { using (var repo = new CursusRepositoryMock()) { //Arrange var target = new CursusController(repo); //Act var result = target.GetByWeek("Faal maar"); //Assert Assert.AreEqual(0, repo.TimesFindByCalled); Assert.IsInstanceOfType(result, typeof(BadRequestObjectResult)); } }
public void VindCursusLijstPerWeekFaalendErrorMessage() { using (var repo = new CursusRepositoryMock()) { //Arrange var target = new CursusController(repo); //Act var result = target.GetByWeek("Faal maar"); //Assert Assert.AreEqual(0, repo.TimesFindByCalled); Assert.IsInstanceOfType(result, typeof(BadRequestObjectResult)); var testResult = (result as BadRequestObjectResult).Value; Assert.AreEqual("datum is niet in juiste format", (testResult as Foutmelding).ErrorMessage); Assert.AreEqual(ErrorTypes.IncorrectInputFormat, (testResult as Foutmelding).ErrorType); } }
public void VindCursusLijstPerWeek() { using (var repo = new CursusRepositoryMock()) { //Arrange Assert.AreEqual(0, repo.TimesFindByCalled); var target = new CursusController(repo); var cursus = new Cursus() { Cursuscode = "test", Duur = 5, Titel = "C# testing" }; var cursusInstantie = new CursusInstantie() { Startdatum = new DateTime(2016, 10, 10), Cursus = cursus }; target.Post(cursusInstantie); var cursusInstantie2 = new CursusInstantie() { Startdatum = new DateTime(2016, 3, 10), Cursus = cursus }; target.Post(cursusInstantie2); //Act target.GetByWeek(new DateTime(2016, 3, 10).ToString()); //Assert Assert.AreEqual(1, repo.TimesFindByCalled); } }