예제 #1
0
 public MovieWithPageSizeController(MovieDbContext context) : base()
 {
     Repository = new EntityTableRepository <EFMovie>(context);
     Options    = new TableControllerOptions {
         PageSize = 25
     };
 }
예제 #2
0
 public SUnitsController(E2EDbContext context)
 {
     TableControllerOptions = new TableControllerOptions <SUnit> {
         SoftDeleteEnabled = true
     };
     TableRepository = new EntityTableRepository <SUnit>(context);
 }
 public RMoviesController(E2EDbContext context)
 {
     TableControllerOptions = new TableControllerOptions <RMovie>
     {
         SoftDeleteEnabled = true
     };
     TableRepository = new EntityTableRepository <RMovie>(context);
 }
예제 #4
0
 public SoftController(MovieDbContext context) : base()
 {
     Repository = new EntityTableRepository <EFMovie>(context);
     Options    = new TableControllerOptions
     {
         EnableSoftDelete = true
     };
 }
예제 #5
0
 public LegalMoviesController(MovieDbContext context) : base()
 {
     Repository            = new EntityTableRepository <EFMovie>(context);
     AccessControlProvider = this;
     Options = new TableControllerOptions {
         UnauthorizedStatusCode = StatusCodes.Status451UnavailableForLegalReasons
     };
 }
예제 #6
0
 public MoviesController(TableServiceContext dbContext)
 {
     TableControllerOptions = new TableControllerOptions <Movie>()
     {
         MaxTop = 1000
     };
     TableRepository = new EntityTableRepository <Movie>(dbContext);
 }
        public void AsQueryable_CanCountItems()
        {
            var dbcontext  = InMemoryContext.GetDbContext();
            var repository = new EntityTableRepository <Movie>(dbcontext);

            var actual = repository.AsQueryable().Count();

            Assert.AreEqual(TestData.Movies.Length, actual);
        }
        public async Task DeleteAsync_ThrowsOnNullId()
        {
            var dbcontext  = InMemoryContext.GetDbContext();
            var repository = new EntityTableRepository <Movie>(dbcontext);

            await repository.DeleteAsync(null);

            Assert.Fail("ArgumentNullException expected");
        }
예제 #9
0
 public SoftLoggedController(MovieDbContext context, ILogger <EFMovie> logger) : base()
 {
     Repository = new EntityTableRepository <EFMovie>(context);
     Options    = new TableControllerOptions
     {
         EnableSoftDelete = true
     };
     Logger = logger;
 }
        public async Task ReplaceAsync_ThrowsOnMissingEntity()
        {
            var dbcontext  = InMemoryContext.GetDbContext();
            var repository = new EntityTableRepository <Movie>(dbcontext);
            var item       = new Movie();

            await repository.ReplaceAsync(item);

            Assert.Fail("EntityDoesNotExistException expected");
        }
        public async Task CreateAsync_Duplicate_Throws()
        {
            var dbcontext  = InMemoryContext.GetDbContext();
            var repository = new EntityTableRepository <Movie>(dbcontext);
            var testItem   = RandomMovie();

            var actual = await repository.CreateAsync(testItem);

            Assert.Fail("EntityExistsException expected");
        }
        public async Task LookupAsync_ReturnsNullOnMissingData()
        {
            var dbcontext  = InMemoryContext.GetDbContext();
            var repository = new EntityTableRepository <Movie>(dbcontext);
            var testId     = "random-invalid-id";

            var actual = await repository.LookupAsync(testId);

            Assert.IsNull(actual);
        }
        public async Task DeleteAsync_ThrowsOnMissingData()
        {
            var dbcontext  = InMemoryContext.GetDbContext();
            var repository = new EntityTableRepository <Movie>(dbcontext);
            var testId     = "random-invalid-id";

            await repository.DeleteAsync(testId);

            Assert.Fail("EntityDoesNotExistException expected");
        }
        public async Task LookupAsync_ReturnsValidData()
        {
            var dbcontext  = InMemoryContext.GetDbContext();
            var repository = new EntityTableRepository <Movie>(dbcontext);
            var testItem   = RandomMovie();

            var actual = await repository.LookupAsync(testItem.Id);

            Assert.IsNotNull(actual);
            Assert.AreEqual(testItem.Title, actual.Title);
        }
        public async Task DeleteAsync_DeletesValidData()
        {
            var dbcontext  = InMemoryContext.GetDbContext();
            var repository = new EntityTableRepository <Movie>(dbcontext);
            var testItem   = RandomMovie();

            await repository.DeleteAsync(testItem.Id);

            var actual = repository.AsQueryable().Count();

            Assert.AreEqual(TestData.Movies.Length - 1, actual);
        }
        public async Task ReplaceAsync_ThrowsOnNullId()
        {
            var dbcontext  = InMemoryContext.GetDbContext();
            var repository = new EntityTableRepository <Movie>(dbcontext);
            var item       = new Movie()
            {
                Id = null
            };

            await repository.ReplaceAsync(item);

            Assert.Fail("ArgumentNullException expected");
        }
        public async Task ReplaceAsync_ReplacesExistingItem()
        {
            var dbcontext  = InMemoryContext.GetDbContext();
            var repository = new EntityTableRepository <Movie>(dbcontext);
            var original   = RandomMovie();

            original.Title = "Test Data";

            var actual = await repository.ReplaceAsync(original);

            Assert.IsNotNull(actual);
            Assert.AreEqual(original.Id, actual.Id);
            Assert.IsTrue(DateTimeOffset.UtcNow.Subtract(actual.UpdatedAt).TotalMilliseconds < 500);
            CollectionAssert.AreEqual(original.Version, actual.Version);
            Assert.AreEqual("Test Data", actual.Title);
            Assert.AreEqual(original.ReleaseDate, actual.ReleaseDate);
        }
        public async Task CreateAsync_CreatesNewItem()
        {
            var dbcontext  = InMemoryContext.GetDbContext();
            var dataset    = dbcontext.Set <Movie>();
            var repository = new EntityTableRepository <Movie>(dbcontext);
            var newItem    = new Movie()
            {
                Title = "Test Item"
            };

            var actual = await repository.CreateAsync(newItem);

            Assert.IsNotNull(actual);
            Assert.AreEqual(32, actual.Id.Length);
            Assert.AreEqual(1, dataset.Count(m => m.Id == actual.Id));
            Assert.IsTrue(DateTimeOffset.UtcNow.Subtract(actual.UpdatedAt).TotalMilliseconds < 500);
            Assert.IsNotNull(actual.Version);
            Assert.AreEqual("Test Item", actual.Title);
        }
 public BlogCommentsController(E2EDbContext context)
 {
     TableRepository = new EntityTableRepository <BlogComment>(context);
 }
예제 #20
0
 public RRatedMoviesController(MovieDbContext context, ILogger <EFMovie> logger) : base()
 {
     Repository            = new EntityTableRepository <EFMovie>(context);
     AccessControlProvider = this;
     Logger = logger;
 }
예제 #21
0
 public MovieController(MovieDbContext context, ILogger <EFMovie> logger) : base()
 {
     Repository = new EntityTableRepository <EFMovie>(context);
     Logger     = logger;
 }
예제 #22
0
 public UnauthorizedController(E2EDbContext context)
 {
     TableRepository = new EntityTableRepository <Movie>(context);
 }
예제 #23
0
 public UnitsController(E2EDbContext context)
 {
     TableRepository = new EntityTableRepository <Unit>(context);
 }
예제 #24
0
 public OfflineReadyController(TableServiceContext dbContext)
 {
     TableRepository = new EntityTableRepository <OfflineReady>(dbContext);
 }
예제 #25
0
 public MoviesController(E2EDbContext context)
 {
     TableRepository = new EntityTableRepository <Movie>(context);
 }
 public BlogPostsController(TableServiceContext dbContext)
 {
     TableRepository = new EntityTableRepository <BlogPost>(dbContext);
 }