Exemplo n.º 1
0
        public void Registreer2x_zelfdeSessie_throwsException()
        {
            Gebruiker gebruiker = new Gebruiker("Sandra Doemsdag", "201734sd", 9876543219876);

            gebruiker.SchrijfGebruikerInSessie(sRgeopendAgeopend);
            Assert.Throws <InvalidOperationException>(() => gebruiker.SchrijfGebruikerInSessie(sRgeopendAgeopend));
        }
        public void SchrijfInVoorSessie_AlIngeschreven_PersisteertNiet()
        {
            _sessieRepository.Setup(m => m.GetById(testSessie.Id)).Returns(testSessie);
            _gebruikerRepository.Setup(m => m.GetByGebruikersnaam(testGebruiker.Gebruikersnaam)).Returns(testGebruiker);
            // piet eerst inschrijven
            testGebruiker.SchrijfGebruikerInSessie(testSessie);

            // Piet opnieuw proberen inschrijven
            var result = Assert.IsType <RedirectToActionResult>(_controller.SchrijfInVoorSessie(testGebruiker, testSessie.Id));

            Assert.Equal(nameof(Index), result.ActionName);
            //Assert.Equal("Gebruiker is al ingeschreven", result.TempData["error"]);
            _sessieRepository.Verify(m => m.SaveChanges(), Times.Never);
        }
Exemplo n.º 3
0
        public void UitschrijvenSessie_verwijderdSessieUitlijst()
        {
            Gebruiker gebruiker = new Gebruiker("Samantha Dompel", "201734sd", 9876543219876);

            Assert.Empty(gebruiker.IngeschrevenSessies);


            gebruiker.SchrijfGebruikerInSessie(sRgeopendAgesloten);
            gebruiker.SchrijfGebruikerUitSessie(sRgeopendAgesloten);
            Assert.Empty(gebruiker.IngeschrevenSessies);

            gebruiker.SchrijfGebruikerInSessie(sRgeopendAgeopend);
            gebruiker.SchrijfGebruikerUitSessie(sRgeopendAgeopend);
            Assert.Empty(gebruiker.IngeschrevenSessies);
        }
Exemplo n.º 4
0
        public void RegistreerAanwezigheid_zetAanwezigTrue()
        {
            Gebruiker gebruiker = new Gebruiker("Sukie Dageraad", "201734sd", 9876543219876);

            gebruiker.SchrijfGebruikerInSessie(sRgeopendAgeopend);
            gebruiker.ZetAanwezigVoorSessie(sRgeopendAgeopend);
            Assert.Single(sRgeopendAgeopend.AanwezigeGebruikers);
        }
Exemplo n.º 5
0
        public void DezelfdeUserAanmelden_ThrowtError()
        {
            _session = MaakDefaultSessie();
            _session.ToState(new RegistratieEnAanmeldenOpenState(_session));
            piet.SchrijfGebruikerInSessie(_session);
            piet.ZetAanwezigVoorSessie(_session);

            Assert.Throws <InvalidOperationException>(() => piet.ZetAanwezigVoorSessie(_session));
        }
Exemplo n.º 6
0
        public void InschrijvenSessie_voegtSessieToe()
        {
            Gebruiker gebruiker = new Gebruiker("Sam Doorsnee", "201734sd", 9876543219876);

            Assert.Empty(gebruiker.IngeschrevenSessies);

            gebruiker.SchrijfGebruikerInSessie(sRgeopendAgesloten);
            Assert.Single(gebruiker.IngeschrevenSessies);
        }
        public void MaakOngeldigeFeedbackEntry_MaaktNietNochPersisteertEntryAndRedirectsToActionIndex()
        {
            //Arrange gebruiker ingeschreven maar niet aanwezig
            Gebruiker testGebruiker2 = _dummyData.jan;

            testGebruiker2.SchrijfGebruikerInSessie(testSessie);
            _sessieRepository.Setup(s => s.GetById(testSessie.Id)).Returns(testSessie);
            _gebruikerRepository.Setup(g => g.GetByGebruikersnaam(testGebruiker2.Gebruikersnaam)).Returns(testGebruiker2);

            var result = Assert.IsType <RedirectToActionResult>(_controller.maakNieuweFeedbackEntry(testGebruiker2, testSessie.Id, "Dit is feedback om te testen", 4));

            Assert.Equal("Index", result?.ActionName);
            _sessieRepository.Verify(m => m.SaveChanges(), Times.Never());
        }
        public FeedbackControllerTest()
        {
            _gebruikerRepository = new Mock <IGebruikerRepository>();
            _sessieRepository    = new Mock <ISessieRepository>();
            _controller          = new FeedBackController(_sessieRepository.Object, _gebruikerRepository.Object)
            {
                TempData = new Mock <ITempDataDictionary>().Object
            };

            _dummyData = new DummyData();
            // testdata ophalen
            testSessie    = _dummyData.s1;
            testGebruiker = _dummyData.piet;
            // testGebruiker inschrijven en aanwezig stellen
            testSessie.ToState(new RegistratieEnAanmeldenOpenState(testSessie));             // zorgen dat gebruiker kan inschrijven en aanmelden
            testGebruiker.SchrijfGebruikerInSessie(testSessie);
            testGebruiker.ZetAanwezigVoorSessie(testSessie);
            // schrijf een feedback
            testGebruiker.geefFeedbackOpSessie(testSessie, "een feedbackinhoud", 5);
        }
        public void SchrijfInVoorSessie_SessieVolzet_PersisteertNiet()
        {
            Sessie volleSessie = new Sessie(hoofdV, "test", "test", new Lokaal("A", 1), DateTime.Today, DateTime.Today.AddHours(1))
            {
                Id = 1
            };
            // schrijf jan in
            Gebruiker jan = new Gebruiker("jan", "987654jj", 9876543219876);

            jan.SchrijfGebruikerInSessie(volleSessie);
            // de sessie is nu vol
            _sessieRepository.Setup(m => m.GetById(volleSessie.Id)).Returns(volleSessie);
            _gebruikerRepository.Setup(m => m.GetByGebruikersnaam(testGebruiker.Gebruikersnaam)).Returns(testGebruiker);
            //probeer piet in te schrijven
            var result = Assert.IsType <RedirectToActionResult>(_controller.SchrijfInVoorSessie(testGebruiker, volleSessie.Id));

            Assert.Equal(nameof(Index), result.ActionName);
            //Assert.Equal("Het lokaal is volzet", result.TempData["error"]);
            _sessieRepository.Verify(m => m.SaveChanges(), Times.Never);
        }
Exemplo n.º 10
0
        public IActionResult SchrijfInVoorSessie(Gebruiker gebruiker, int sessieId)
        {
            // de entities moeten getracked worden voor het updaten van de db
            Sessie    trackedSessie    = _sessieRepository.GetById(sessieId);
            Gebruiker trackedGebruiker = _gebruikerRepository.GetByGebruikersnaam(gebruiker.Gebruikersnaam);

            if (trackedSessie == null)               // De sessie bestaat niet
            {
                TempData["error"] = "De sessie bestaat niet";
                return(RedirectToAction(nameof(Index)));
            }

            try {
                trackedGebruiker.SchrijfGebruikerInSessie(trackedSessie);
                // dit is om op te slaan in de db
                _sessieRepository.SaveChanges();
                TempData["message"] = $"Inschrijven voor sessie '{trackedSessie.Titel}' succesvol!";
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception e) {
                TempData["error"] = e.Message;
                return(RedirectToAction(nameof(Index)));
            }
        }
Exemplo n.º 11
0
        public async Task InitializeData()
        {
            // Op het juiste moment uit commentaar zetten om te voorkomen dat je de db steeds opnieuw maakt
            _context.Database.EnsureDeleted();
            if (_context.Database.EnsureCreated())
            {
                //if (!_context.Sessies.Any()) {

                ISessieRepository sessieRepo = new SessieRepository(_context);

                HoofdVerantwoordelijke labijn = new HoofdVerantwoordelijke("Sebastiaan Labijn", "987654sl", 1234567891234);
                Verantwoordelijke      gates  = new Verantwoordelijke("Bill Gates", "789456bg", 9876543219876);
                Verantwoordelijke      obama  = new Verantwoordelijke("Barack Obama", "654123bo", 7412589631478);

                Lokaal b1025 = new Lokaal("B1.025", 50);
                Lokaal b2036 = new Lokaal("B2.036", 80);
                Lokaal b4026 = new Lokaal("B4.026", 30);

                Gebruiker geb1 = new Gebruiker("Kevin Degrote", "123456kd", 9512634879548);
                Gebruiker geb2 = new Gebruiker("Hans Peters", "123456hp", 0321456987589);


                IList <Gebruiker> gebruikers = new List <Gebruiker> {
                    geb1, geb2, labijn, obama, gates
                };

                await InitializeUsers(gebruikers.ToArray());

                Sessie sessie1 = new Sessie(labijn, "Angular Update", "Geen", b1025, new DateTime(2020, 04, 13, 12, 30, 00), new DateTime(2020, 04, 13, 13, 25, 00));


                Sessie sessie2 = new Sessie(obama, "How to Switch from Carrier", "Michelle Obama", b2036, new DateTime(2020, 04, 13, 12, 30, 00), new DateTime(2020, 04, 13, 13, 30, 00));


                Sessie sessie3 = new Sessie(gates, "Windows 20 Conference", "Geen", b1025, new DateTime(2020, 04, 16, 14, 30, 00), new DateTime(2020, 04, 16, 16, 30, 00));


                Sessie sessie4 = new Sessie(labijn, "C++ Intro", "Thomas Kempens", b4026, new DateTime(2020, 06, 09, 14, 30, 00), new DateTime(2020, 06, 09, 18, 30, 00));


                Sessie sessie5 = new Sessie(gates, "How to be a Good Programmer ?", "Geen", b4026, new DateTime(2020, 06, 20, 12, 30, 00), new DateTime(2020, 06, 20, 12, 25, 00), new List <Media>()
                {
                    new Media("/images/MediaImages/BillGatesProjecten.jpg"), new Media("/images/MediaFiles/BillGates.pdf"), new Media("/images/MediaLinks/BillGates.txt")
                });

                Sessie sessie6 = new Sessie(obama, "Advanced SQL", "Angeline Van Achter", b2036, new DateTime(2020, 06, 24, 09, 30, 00), new DateTime(2020, 06, 24, 12, 30, 00));


                Sessie sessie7 = new Sessie(labijn, "Advanced python", "Geen", b1025, new DateTime(2020, 08, 14, 14, 30, 00), new DateTime(2020, 08, 14, 17, 30, 00));


                Sessie sessie8 = new Sessie(gates, "Why Ruby on Rails ?", "Ruby expert", b4026, new DateTime(2020, 08, 15, 12, 30, 00), new DateTime(2020, 08, 15, 14, 30, 00));


                Sessie sessie9 = new Sessie(obama, "Java for newbies", "Geen", b4026, new DateTime(2020, 08, 28, 10, 00, 00), new DateTime(2020, 08, 28, 11, 00, 00));

                Sessie sessie10 = new Sessie(obama, "Java for pros", "Geen", b4026, new DateTime(2020, 08, 28, 10, 00, 00), new DateTime(2020, 08, 28, 11, 00, 00));


                // DIT WORDT NU AUTOMATISCHE GEDAAN IN DE SESSIEREPO
                //sessie2.OpenVoorAanmelden();

                //sessie3.OpenVoorAanmelden();

                //sessie7.OpenVoorAanmelden();
                //sessie7.SluitVoorRegistratie();

                //sessie9.OpenVoorAanmelden();
                //sessie9.SluitVoorRegistratie();
                //sessie9.SluitSessie();


                //! dit gaat indirect de sessiestates updaten
                sessieRepo.GetAll();
                //!

                _context.Sessies.AddRange(sessie1, sessie2, sessie3, sessie4, sessie5, sessie6, sessie7, sessie8, sessie9, sessie10);
                _context.SaveChanges();


                //geb1.SchrijfGebruikerInSessie(sessie1);
                //geb1.SchrijfGebruikerInSessie(sessie2);
                //geb1.SchrijfGebruikerInSessie(sessie3);
                geb1.SchrijfGebruikerInSessie(sessie4);
                geb1.SchrijfGebruikerInSessie(sessie5);
                geb1.SchrijfGebruikerInSessie(sessie8);

                geb2.SchrijfGebruikerInSessie(sessie4);
                geb2.SchrijfGebruikerInSessie(sessie5);
                geb2.SchrijfGebruikerInSessie(sessie7);

                //geb1.ZetAanwezigVoorSessie(sessie2);
                //geb1.ZetAanwezigVoorSessie(sessie3);


                _context.SaveChanges();
            }
        }