Ejemplo n.º 1
0
        public async Task AddAsyncShouldWork()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "AddAsyncShouldWork").Options;
            var dbContext  = new ApplicationDbContext(options);
            var repository = new EfDeletableEntityRepository <Model>(dbContext);
            var service    = new ModelsService(repository);

            Assert.Empty(service.GetAll());

            await service.AddAsync("M5", new Make());

            Assert.Single(service.GetAll());
        }
Ejemplo n.º 2
0
        public async Task GetAllGenericShouldWork()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "GetAllGenericShouldWork").Options;
            var dbContext = new ApplicationDbContext(options);

            dbContext.Models.Add(new Model()
            {
                Name = "1", MakeId = 1
            });
            dbContext.Models.Add(new Model()
            {
                Name = "2", MakeId = 2
            });
            dbContext.Models.Add(new Model()
            {
                Name = "3", MakeId = 3
            });
            await dbContext.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <Model>(dbContext);
            var service    = new ModelsService(repository);

            Assert.Equal(3, service.GetAll <ModelsReturnModel>().Count());
        }