Example #1
0
        public async Task TestCreateMeeting()
        {
            ACMDbContext    context         = ACMDbContextInMemoryFactory.InitializeContext();
            MeetingsService meetingsService = new MeetingsService(context);
            List <VoteDTO>  votes;

            votes = CreateVotes();
            string output = await meetingsService.CreateMeeting("Beer", votes);

            Assert.Single(context.Meetings.ToList());
            Assert.True(context.Meetings.Any(x => x.Id == output));
            Meeting meeting = context.Meetings.Where(x => x.Id == output).FirstOrDefault();

            Assert.Equal("Beer", meeting.Text);
            Assert.Equal(3, meeting.Votes.Count());
            Assert.Equal("text1", meeting.Votes.ToList()[0].Text);
            Assert.Equal(1, meeting.Votes.ToList()[0].Yes);
            Assert.Equal(1, meeting.Votes.ToList()[0].No);
            Assert.Equal("text2", meeting.Votes.ToList()[1].Text);
            Assert.Equal(2, meeting.Votes.ToList()[1].Yes);
            Assert.Equal(2, meeting.Votes.ToList()[1].No);
            Assert.Equal("text3", meeting.Votes.ToList()[2].Text);
            Assert.Equal(3, meeting.Votes.ToList()[2].Yes);
            Assert.Equal(3, meeting.Votes.ToList()[2].No);
        }
Example #2
0
 public MeetingsController(MeetingsService meetingsService,
                           UsersService usersService, MsgQueueService msgQueueService)
 {
     _meetingsService = meetingsService;
     _usersService    = usersService;
     _msgQueueService = msgQueueService;
 }
Example #3
0
        public ActionResult Delete(int id)
        {
            MeetingsService.Delete(id);

            Notice("Du føler dig destruktiv idag, hva? Pyt. Mødet er dæbt.");

            return(RedirectToAction("Index"));
        }
Example #4
0
        public void TestGetAllMeetingsEmptyTable()
        {
            ACMDbContext           context         = ACMDbContextInMemoryFactory.InitializeContext();
            MeetingsService        meetingsService = new MeetingsService(context);
            List <MeetingsListDTO> output          = meetingsService.GetAllMeetings();

            Assert.Empty(output);
        }
Example #5
0
        public async Task TestEditMeetingInvalidId()
        {
            ACMDbContext    context         = ACMDbContextInMemoryFactory.InitializeContext();
            MeetingsService meetingsService = new MeetingsService(context);
            string          id = await CreateAMeeting(context);

            await Assert.ThrowsAsync <ACMException>(() => meetingsService
                                                    .EditMeeting(id + "Random string", "new text", new List <VoteDTO>()));
        }
Example #6
0
        public async Task TestDeleteMeetingInvalidId()
        {
            ACMDbContext    context         = ACMDbContextInMemoryFactory.InitializeContext();
            MeetingsService meetingsService = new MeetingsService(context);
            string          id = await CreateAMeeting(context);

            await Assert.ThrowsAsync <ACMException>(()
                                                    => meetingsService.DeleteMeeting(id + "Random string"));
        }
Example #7
0
        public async Task TestGetOneMeetingInvalidId()
        {
            ACMDbContext    context         = ACMDbContextInMemoryFactory.InitializeContext();
            MeetingsService meetingsService = new MeetingsService(context);
            string          id = await CreateAMeeting(context);

            Action act = () => meetingsService.GetOneMeeting(id + "Random string");

            Assert.Throws <ACMException>(act);
        }
Example #8
0
        public async Task TestEditMeetingGoodData()
        {
            ACMDbContext    context         = ACMDbContextInMemoryFactory.InitializeContext();
            MeetingsService meetingsService = new MeetingsService(context);
            string          id = await CreateAMeeting(context);

            bool output = await meetingsService.EditMeeting(id, "new text", new List <VoteDTO>());

            Assert.True(output);
            Assert.Equal("new text", context.Meetings.Where(x => x.Id == id).FirstOrDefault().Text);
            Assert.Empty(context.Votes.ToList());
        }
Example #9
0
        public ActionResult Edit(int id, MeetingFormModel formModel)
        {
            LoadFormData();

            if (ModelState.IsValid)
            {
                MeetingsService.Save(id, formModel);
                Notice("Se dit flotte møde :)");
                return(RedirectToAction("Show", new { id }));
            }

            return(View("Create", formModel));
        }
Example #10
0
        public ActionResult Create(MeetingFormModel formModel)
        {
            LoadFormData();

            if (ModelState.IsValid)
            {
                var meeting = MeetingsService.Create(formModel);
                Notice("Se dit flotte møde :)");
                return(RedirectToAction("Show", new { id = meeting.Id }));
            }

            return(View(formModel));
        }
Example #11
0
        public async Task TestDeleteMeetingGoodData()
        {
            ACMDbContext    context         = ACMDbContextInMemoryFactory.InitializeContext();
            MeetingsService meetingsService = new MeetingsService(context);
            string          id = await CreateAMeeting(context);

            string id2 = await CreateAMeeting(context);

            bool output = await meetingsService.DeleteMeeting(id);

            Assert.True(output);
            Assert.Single(context.Meetings.ToList());
            Assert.Equal(3, context.Votes.ToList().Count);
            Assert.True(context.Meetings.Any(x => x.Id == id2));
        }
Example #12
0
        public ActionResult Pull()
        {
            var client = new WebClient();

            client.Encoding = System.Text.Encoding.UTF8;
            var result = client.DownloadString("http://www.geekhub.dk/meetings.json?ticks=" + DateTime.Now.Ticks);
            var json   = JsonConvert.DeserializeObject <JsonViewModel>(result);

            MeetingsService.DeleteAll();

            foreach (var meeting in json.Items)
            {
                MeetingsService.Create(meeting);
            }

            return(Content("Completed"));
        }
Example #13
0
        public async Task TestGetAllMeetingsGoodData()
        {
            ACMDbContext    context         = ACMDbContextInMemoryFactory.InitializeContext();
            MeetingsService meetingsService = new MeetingsService(context);
            string          id1             = await CreateAMeeting(context);

            string id2 = await CreateAMeeting(context);

            List <MeetingsListDTO> output = meetingsService.GetAllMeetings();

            Assert.Equal(2, output.Count);
            Assert.Equal(3, output[0].NumberOfVotes);
            Assert.Equal("beer", output[0].Text);
            Assert.Equal(id2, output[0].Id);
            Assert.Equal(3, output[1].NumberOfVotes);
            Assert.Equal("beer", output[1].Text);
            Assert.Equal(id1, output[1].Id);
        }
Example #14
0
        public async Task TestGetOneMeetingGoodData()
        {
            ACMDbContext    context         = ACMDbContextInMemoryFactory.InitializeContext();
            MeetingsService meetingsService = new MeetingsService(context);
            string          id = await CreateAMeeting(context);

            MeetingDetailsDTO output = meetingsService.GetOneMeeting(id);

            Assert.Equal(id, output.Id);
            Assert.Equal("beer", output.Text);
            Assert.Equal("text1", output.Votes[0].Text);
            Assert.Equal(1, output.Votes[0].Yes);
            Assert.Equal(1, output.Votes[0].No);
            Assert.Equal("text2", output.Votes[1].Text);
            Assert.Equal(2, output.Votes[1].Yes);
            Assert.Equal(2, output.Votes[1].No);
            Assert.Equal("text3", output.Votes[2].Text);
            Assert.Equal(3, output.Votes[2].Yes);
            Assert.Equal(3, output.Votes[2].No);
        }