Example #1
0
        public void GetModelByNameShouldThrowNullExceptionForInvalidName(string name)
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "AddAsyncShouldThrowNullExceptionForInvalidName").Options;
            var dbContext  = new ApplicationDbContext(options);
            var repository = new EfDeletableEntityRepository <Model>(dbContext);
            var service    = new ModelsService(repository);

            Assert.Throws <ArgumentNullException>(() => service.GetModelByName(name));
        }
Example #2
0
        public async Task GetModelByNameShouldWork()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "GetModelByNameShouldWork").Options;
            var dbContext  = new ApplicationDbContext(options);
            var repository = new EfDeletableEntityRepository <Model>(dbContext);
            var service    = new ModelsService(repository);

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

            Assert.Equal("M5", service.GetModelByName("M5").Name);
        }