<commit_before>﻿using System;
using System.Linq;
using NUnit.Framework;
using ToastmasterScheduler.Domain;
using ToastmasterScheduler.Web;

namespace ToastmasterScheduler.IntegrationTest
{
    [TestFixture]
    public class schedule_meetings : IntegrationTestBase
    {
        [Test]
        public void initialize_meeting_from_template()
        {
            //arrange
            int meetingId;
            MeetingTemplate meetingTemplate;
            var meetingDate = DateTime.Now;

            using (var session = DocumentStore.OpenSession())
            {
                meetingTemplate = session.Query<MeetingTemplate>().First(t => t.Enabled);
                var scheduler = new MeettingScheduler(session);
                
                //act
                var meeting = scheduler.Initialize(meetingTemplate, meetingDate);

                session.Store(meeting);
                meetingId = meeting.Id;
                session.SaveChanges();
            }

            //assert
            using (var session = DocumentStore.OpenSession())
            {
                var meeting = session.Load<Meeting>(meetingId);

                Assert.AreEqual(meetingDate, meeting.DateTime);
                CollectionAssert.AreEqual(meetingTemplate.Items.Select(i => i.Role.Id), meeting.Items.Select(i => i.Role.Id));
            }
        }

        [Test]
        public void fill_vacancies_for_a_meeting()
        {
            //arrange
            int meetingId;
            var meetingDate = DateTime.Now;

            using (var session = DocumentStore.OpenSession())
            {
                var meetingTemplate = session.Query<MeetingTemplate>().First(t => t.Enabled);

                var scheduler = new MeettingScheduler(session);
                var meeting = scheduler.Initialize(meetingTemplate, meetingDate);

                //act
                scheduler.FillVacancies(meeting);

                session.Store(meeting);
                meetingId = meeting.Id;
                session.SaveChanges();
            }

            //assert
            using (var session = DocumentStore.OpenSession())
            {
                var meeting = session.Load<Meeting>(meetingId);

                CollectionAssert.AllItemsAreNotNull(meeting.Items.Select(i => i.Member));
                CollectionAssert.AllItemsAreUnique(meeting.Items.Select(i => i.Member.Id));
                //Assert.AreEqual(meetingDate, meeting.DateTime);
                //CollectionAssert.AreEqual(meetingTemplate.Items.Select(i => i.Role.Id), meeting.Items.Select(i => i.Role.Id));
            }
        }
    }
}<commit_msg>Added todo list in test<commit_after>﻿using System;
using System.Linq;
using NUnit.Framework;
using ToastmasterScheduler.Domain;
using ToastmasterScheduler.Web;

namespace ToastmasterScheduler.IntegrationTest
{
    [TestFixture]
    public class schedule_meetings : IntegrationTestBase
    {
        [Test]
        public void initialize_meeting_from_template()
        {
            //arrange
            int meetingId;
            MeetingTemplate meetingTemplate;
            var meetingDate = DateTime.Now;

            using (var session = DocumentStore.OpenSession())
            {
                meetingTemplate = session.Query<MeetingTemplate>().First(t => t.Enabled);
                var scheduler = new MeettingScheduler(session);
                
                //act
                var meeting = scheduler.Initialize(meetingTemplate, meetingDate);

                session.Store(meeting);
                meetingId = meeting.Id;
                session.SaveChanges();
            }

            //assert
            using (var session = DocumentStore.OpenSession())
            {
                var meeting = session.Load<Meeting>(meetingId);

                Assert.AreEqual(meetingDate, meeting.DateTime);
                CollectionAssert.AreEqual(meetingTemplate.Items.Select(i => i.Role.Id), meeting.Items.Select(i => i.Role.Id));
            }
        }

        [Test]
        public void fill_vacancies_for_a_meeting()
        {
            //arrange
            int meetingId;
            var meetingDate = DateTime.Now;

            using (var session = DocumentStore.OpenSession())
            {
                var meetingTemplate = session.Query<MeetingTemplate>().First(t => t.Enabled);

                var scheduler = new MeettingScheduler(session);
                var meeting = scheduler.Initialize(meetingTemplate, meetingDate);

                //act
                scheduler.FillVacancies(meeting);

                session.Store(meeting);
                meetingId = meeting.Id;
                session.SaveChanges();
            }

            //assert
            using (var session = DocumentStore.OpenSession())
            {
                var meeting = session.Load<Meeting>(meetingId);

                CollectionAssert.AllItemsAreNotNull(meeting.Items.Select(i => i.Member));
                CollectionAssert.AllItemsAreUnique(meeting.Items.Select(i => i.Member.Id));
            }
        }

        //todo:implement some of the roles may not require members assigned
        //todo:add a test that some vacancies are filled manually before auto-fill process
        
    }
}
{'fraction_non_alphanumeric': 0.09177456207159178, 'fraction_numerical': 0.0, 'mean_word_length': 1.7402190923317684, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7063079', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1272, 'n_words': 246}