Example #1
0
        private static ODataReadOnlyControllerBase <T, TKey, FakeDbContext> CreateControllerWithData <T, TKey>(IQueryable <T> data, Func <TKey, Expression <Func <T, bool> > > primaryKeyPredicate) where T : class
        {
            var dbContext  = DatabaseMocker.GetMockedDbContext <FakeDbContext, T>(data);
            var controller = new ODataReadOnlyControllerBase <T, TKey, FakeDbContext>(new NLogLogger(), UserHelper.CreateTestCurrentUser(), dbContext.Object, primaryKeyPredicate);

            return(controller);
        }
Example #2
0
        public void ControllerHasNoDataTest()
        {
            //Given:
            var data       = new List <TestBasicGuid>().AsQueryable();
            var dbContext  = DatabaseMocker.GetMockedDbContext <FakeDbContext, TestBasicGuid>(data);
            var controller = new ODataReadOnlyControllerBase <TestBasicGuid, Guid, FakeDbContext>(new NLogLogger(), UserHelper.CreateTestCurrentUser(), dbContext.Object, key => x => x.ID == key);

            //When:
            var result = controller.Get().ToList();

            //Then:
            Assert.IsEmpty(result, "An empty list was expected.");
        }