public async Task Get_FromODataURI()
        {
            using (IDataContext context = GetDataContext())
            using (IRaceDataUnitOfWork uow = new RaceDataUnitOfWork(context, new Logger()))
            {
                //Arrange
                MeetingsController controller = new MeetingsController(uow);

                await SetupData(controller, uow, false);

                Meeting mock = mockmeetings.ElementAt(1);
                //Act
                IHttpActionResult post_response = await controller.Post(mock);
                CreatedNegotiatedContentResult<Meeting> post_actual = post_response as CreatedNegotiatedContentResult<Meeting>;

                // Assert
                Assert.IsNotNull(post_actual, "A response equal to null is unexpected!");

                //Act
                IHttpActionResult response = await controller.Get(post_actual.Content.Id);
                OkNegotiatedContentResult<IEnumerable<Meeting>> actual = response as OkNegotiatedContentResult<IEnumerable<Meeting>>;

                //Assert
                // Assert
                Assert.IsNotNull(actual, "A response equal to null is unexpected!");
                Assert.AreEqual(actual.Content.ElementAt(0).VenueName, mock.VenueName);
                Assert.AreEqual(actual.Content.ElementAt(0).NumberOfRaces, mock.NumberOfRaces);
                Assert.AreEqual(actual.Content.ElementAt(0).Coverages.Count(), mock.Coverages.Count());
                Assert.AreEqual(actual.Content.ElementAt(0).RaceStarts.Count(), mock.RaceStarts.Count());
            }
        }
        public async Task GetMeetings_Query_GetAsync()
        {
            using (IDataContext context = GetDataContext())
            using (IRaceDataUnitOfWork uow = new RaceDataUnitOfWork(context, new Logger()))
            {
                //Setup
                await PopulateData(uow);

                IEnumerable<Meeting> actual = await uow.MeetingsRepository.Query().GetAsync();

                Assert.IsInstanceOfType(actual, typeof(IEnumerable<Meeting>));
                Assert.AreEqual(2, actual.Count());
                Assert.AreEqual(actual.FirstOrDefault().VenueName, mockmeetings.FirstOrDefault().VenueName);
                Assert.AreEqual(actual.FirstOrDefault().NumberOfRaces, mockmeetings.FirstOrDefault().NumberOfRaces);
                Assert.AreEqual(actual.FirstOrDefault().Coverages.Count(), mockmeetings.FirstOrDefault().Coverages.Count());
                Assert.AreEqual(actual.FirstOrDefault().RaceStarts.Count(), mockmeetings.FirstOrDefault().RaceStarts.Count());
            }
        }
        public async Task Delete()
        {
            using (IDataContext context = GetDataContext())
            using (IRaceDataUnitOfWork uow = new RaceDataUnitOfWork(context, new Logger()))
            {          
                //Arrange
                MeetingsController controller = new MeetingsController(uow);

                await SetupData(controller, uow);

                // Expected
                Meeting expected = mockmeetings.ElementAt(1);

                //Act
                IHttpActionResult response = await controller.Delete(expected.Id);
                StatusCodeResult actual = response as StatusCodeResult;

                // Assert
                Assert.IsNotNull(actual, "A response equal to null is unexpected!");
                Assert.AreEqual(actual.StatusCode, HttpStatusCode.NoContent);
            }
        }
        public async Task Patch_NotExistingEntity()
        {
            using (IDataContext context = GetDataContext())
            using (IRaceDataUnitOfWork uow = new RaceDataUnitOfWork(context, new Logger()))
            {
                //Arrange
                MeetingsController controller = new MeetingsController(uow);

                await SetupData(controller, uow);

                // Expected
                Meeting expected = mockmeetings.ElementAt(1);

                Delta<Meeting> delta = new Delta<Meeting>(typeof(Meeting));
                delta.TrySetPropertyValue("VenueName", expected.VenueName + " Patched");

                //Act
                IHttpActionResult response = await controller.Patch(1, delta);

                // Assert
                Assert.IsNotNull(response, "A response equal to null is unexpected!");
                Assert.IsInstanceOfType(response, typeof(NotFoundResult));
            }
        }
        public async Task Patch()
        {
            using (IDataContext context = GetDataContext())
            using (IRaceDataUnitOfWork uow = new RaceDataUnitOfWork(context, new Logger()))
            {
                //Arrange
                MeetingsController controller = new MeetingsController(uow);

                await SetupData(controller, uow, false);

                // Expected
                Meeting expected = mockmeetings.ElementAt(0);

                Delta<Meeting> delta = new Delta<Meeting>(typeof(Meeting));
                delta.TrySetPropertyValue("VenueName", expected.VenueName + " Patched");

                //Act
                IHttpActionResult post_response = await controller.Post(mockmeetings.ElementAt(0));
                CreatedNegotiatedContentResult<Meeting> post_actual = post_response as CreatedNegotiatedContentResult<Meeting>;

                // Assert
                Assert.IsNotNull(post_actual, "A response equal to null is unexpected!");

                //Act
                IHttpActionResult response = await controller.Patch(post_actual.Content.Id, delta);
                UpdatedODataResult<Meeting> actual = response as UpdatedODataResult<Meeting>;

                // Assert
                Assert.IsNotNull(actual, "A response equal to null is unexpected!");
                Assert.AreEqual(actual.Entity.VenueName, expected.VenueName);
                Assert.AreEqual(actual.Entity.NumberOfRaces, expected.NumberOfRaces);
                Assert.AreEqual(actual.Entity.Coverages.Count(), expected.Coverages.Count());
                Assert.AreEqual(actual.Entity.RaceStarts.Count(), expected.RaceStarts.Count());
            }
        }
        public async Task Post()
        {
            using (IDataContext context = GetDataContext())
            using (IRaceDataUnitOfWork uow = new RaceDataUnitOfWork(context, new Logger()))
            {
                //Arrange
                MeetingsController controller = new MeetingsController(uow);

                await SetupData(controller, uow, false);

                //Act
                IHttpActionResult response = await controller.Post(mockmeetings.ElementAt(1));
                CreatedNegotiatedContentResult<Meeting> actual = response as CreatedNegotiatedContentResult<Meeting>;

                //Assert
                // Assert
                Assert.IsNotNull(actual, "A response equal to null is unexpected!");
                Assert.AreEqual(actual.Content.VenueName, mockmeetings.ElementAt(1).VenueName);
                Assert.AreEqual(actual.Location, "http://localhost:1234/odata/meetings/" + mockmeetings.ElementAt(1).Id.ToString());

                IEnumerable<Meeting> check_meetings = await uow.MeetingsRepository.Query().GetAsync();
                Assert.IsNotNull(check_meetings, "A response equal to null is unexpected!");
                Assert.AreEqual(check_meetings.Count(),1);
            }
        }
        public async Task FindMeetingById()
        {
            using (IDataContext context = GetDataContext())
            using (IRaceDataUnitOfWork uow = new RaceDataUnitOfWork(context, new Logger()))
            {
                await PopulateData(uow);

                var meeting = uow.MeetingsRepository.Find(1);

                Assert.IsNotNull(meeting);
                Assert.AreEqual(meeting.Id, 1);
            }
        }
        public async Task DeleteMeetingByMeeting()
        {
            using (IDataContext context = GetDataContext())
            using (IRaceDataUnitOfWork uow = new RaceDataUnitOfWork(context, new Logger()))
            {
                await PopulateData(uow);

                uow.MeetingsRepository.Delete(mockmeetings.ElementAt(0));

                await uow.CommitAsync();

                var meeting = uow.MeetingsRepository.Find(0);

                Assert.IsNull(meeting);
            }
        }
        public async Task UpdateMeeting()
        {
            using (IDataContext context = GetDataContext())
            using (IRaceDataUnitOfWork uow = new RaceDataUnitOfWork(context, new Logger()))
            {
                await PopulateData(uow);

                Meeting updatedEntity = mockmeetings.ElementAt(0);
                updatedEntity.VenueName += updatedEntity.VenueName + " Updated";

                uow.MeetingsRepository.Update(updatedEntity);

                var meeting = await uow.MeetingsRepository.FindAsync(0);

                Assert.IsNotNull(meeting);
                Assert.AreEqual(meeting.Id, 0);
                Assert.AreEqual(meeting.VenueName, updatedEntity.VenueName);
            }
        }