Beispiel #1
0
        public void InsertCursusFaalendDuplicateErrorMessage()
        {
            using (var repo = new CursusRepositoryMock())
            {
                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);


                //Act
                var result = target.Post(cursusInstantie);

                //Assert
                Assert.AreEqual(2, repo.TimesInsertCalled);
                Assert.IsInstanceOfType(result, typeof(BadRequestObjectResult));
                var testResult = (result as BadRequestObjectResult).Value;
                Assert.AreEqual("This key already exist", (testResult as Foutmelding).ErrorMessage);
            }
        }
Beispiel #2
0
        public void InsertCursusFaalendDuplicate()
        {
            using (var repo = new CursusRepositoryMock())
            {
                //Arrange

                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);


                //Act
                var result = target.Post(cursusInstantie);

                //Assert
                Assert.AreEqual(2, repo.TimesInsertCalled);
                Assert.IsInstanceOfType(result, typeof(BadRequestObjectResult));
            }
        }
Beispiel #3
0
        public void CursusPostTest()
        {
            using (var repo = new CursusRepositoryMock())
            {
                //Arrange
                Assert.AreEqual(0, repo.TimesInsertCalled);

                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
                };
                //Act
                target.Post(cursusInstantie);
                //Assert
                Assert.AreEqual(1, repo.TimesInsertCalled);
                Assert.AreEqual(cursusInstantie, repo.InsertLastCallContent);
            }
        }
Beispiel #4
0
        public void CursusPostTimesCalledTest()
        {
            // Arrange
            using (var repositoryMock = new CursusRepositoryMock())
            {
                var target = new CursusController(repositoryMock);

                // Act
                target.Post(new Cursus());
                target.Post(new Cursus());
                var result = target.Post(new Cursus());

                // Assert
                Assert.AreEqual(3, repositoryMock.TimesCalled);
                Assert.IsInstanceOfType(result, typeof(OkResult));
            }
        }
        public void CursusPostTest()
        {
            using (var repo = new CursusRepositoryMock())
            {
                Assert.AreEqual(0, repo.TimesCalled);

                var target = new CursusController(repo);

                target.Post(new Inschrijving());

                Assert.AreEqual(1, repo.TimesCalled);
            }
        }
Beispiel #6
0
        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);
            }
        }