Example #1
0
        public void Delete_ExistingEvenement()
        {
            DataAccessProvider dp = new DataAccessProvider(_context);

            Evenement existingEvent = dp.GetEventById(1);

            var deletedEvent = new EvenementController(_context).Delete(existingEvent.id);

            Assert.IsInstanceOfType(deletedEvent, typeof(OkResult));

            int nbEvent = dp.GetAllEvent().Count;

            nbEvent.Should().Be(1);

            Evenement nullEvent = dp.GetEventById(existingEvent.id);

            nullEvent.Should().BeNull();
        }
Example #2
0
        public void Post_NewEvenement()
        {
            DataAccessProvider dp    = new DataAccessProvider(_context);
            List <string>      liste = new List <string>();
            Evenement          e     = new Evenement(0, "test", "test", "test", liste);
            var evenementAdded       = new EvenementController(_context).Post(e);

            Assert.IsInstanceOfType(evenementAdded, typeof(CreatedResult));
            CreatedResult cEvenementAdded = (CreatedResult)evenementAdded;

            Evenement eventAdded = (Evenement)cEvenementAdded.Value;

            int nbEvent = dp.GetAllEvent().Count;

            nbEvent.Should().Be(3);

            eventAdded.id.Should().Be(e.id);
            eventAdded.titre.Should().Be(e.titre);
            eventAdded.description.Should().Be(e.description);
        }
Example #3
0
        public void Put_ExistingEvenement()
        {
            DataAccessProvider dp            = new DataAccessProvider(_context);
            Evenement          existingEvent = dp.GetEventById(1);

            existingEvent.titre += "modification du titre";

            var updatedEvent = new EvenementController(_context).Put(existingEvent.id, existingEvent);

            Assert.IsInstanceOfType(updatedEvent, typeof(OkResult));

            int       nbEvent = dp.GetAllEvent().Count;
            Evenement dbEvent = dp.GetEventById(existingEvent.id);

            nbEvent.Should().Be(2);

            dbEvent.id.Should().Be(existingEvent.id);
            dbEvent.titre.Should().Be(existingEvent.titre);
            dbEvent.description.Should().Be(existingEvent.description);
            dbEvent.personneresponsable.Should().Be(existingEvent.personneresponsable);
            dbEvent.listecommentaire.Should().BeEquivalentTo(existingEvent.listecommentaire);
        }
Example #4
0
        public ActionResult <IEnumerable <Evenement> > Get()
        {
            List <Evenement> evenements = dataProvider.GetAllEvent();

            return(Ok(evenements));
        }