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 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());
            }
        }
        private async Task SetupData(MeetingsController controller, IRaceDataUnitOfWork uow, bool withNewData = true)
        {
            //clear previously added data from DB
            var ms = uow.MeetingsRepository.Query().Get();

            foreach (var m in ms)
            {
                uow.MeetingsRepository.Delete(m.Id);
            }
            var x = await uow.CommitAsync();

            if (withNewData)
            {
                //Setup
                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!");
                post_response = await controller.Post(mockmeetings.ElementAt(1));
                post_actual = post_response as CreatedNegotiatedContentResult<Meeting>;
                // Assert
                Assert.IsNotNull(post_actual, "A response equal to null is unexpected!");
            }
        }
        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);
            }
        }