public DroidRepositoryShould()
        {
            // Given
            var logger = new Mock <ILogger <DroidRepository> >();

            _droidRepository = new DroidRepository(logger.Object);
        }
        public DroidRepositoryShould()
        {
            var dbLogger = new Mock <ILogger <InMemoryContext> >();
            var db       = new InMemoryContext(dbLogger.Object);

            var logger = new Mock <ILogger <DroidRepository> >();

            _droidRepository = new DroidRepository(db, logger.Object);
        }
Beispiel #3
0
        public DroidRepositoryShould()
        {
            // Given
            _dbLogger = new Mock <ILogger <StarWarsContext> >();
            // https://docs.microsoft.com/en-us/ef/core/miscellaneous/testing/in-memory
            _options = new DbContextOptionsBuilder <StarWarsContext>()
                       .UseInMemoryDatabase(databaseName: "StarWars_DroidRepositoryShould")
                       .Options;
            using (var context = new StarWarsContext(_options, _dbLogger.Object))
            {
                context.EnsureSeedData();
            }
            var starWarsContext = new StarWarsContext(_options, _dbLogger.Object);
            var repoLogger      = new Mock <ILogger <DroidRepository> >();

            _droidRepository = new DroidRepository(starWarsContext, repoLogger.Object);
        }
        public DroidRepositoryShould()
        {
            var dbLogger = new Mock <ILogger <Context> >();

            var options = new DbContextOptionsBuilder <Context>()
                          .UseInMemoryDatabase(databaseName: "StarWars")
                          .Options;

            using (var context = new Context(options, dbLogger.Object))
            {
                context.Droids.Add(new Droid {
                    Id = 1, Name = "R2-D2"
                });
                context.SaveChanges();
            }

            var starWarsContext = new Context(options, dbLogger.Object);
            var repoLogger      = new Mock <ILogger <DroidRepository> >();

            _droidRepository = new DroidRepository(starWarsContext, repoLogger.Object);
        }
        public DroidRepositoryShould()
        {
            // Given
            var dbLogger = new Mock <ILogger <StarWarsContext> >();
            // https://docs.microsoft.com/en-us/ef/core/miscellaneous/testing/in-memory
            var options = new DbContextOptionsBuilder <StarWarsContext>()
                          .UseInMemoryDatabase(databaseName: "StarWars")
                          .Options;

            using (var context = new StarWarsContext(options, dbLogger.Object))
            {
                context.Droids.Add(new Droid {
                    Id = 1, Name = "R2-D2"
                });
                context.SaveChanges();
            }
            var starWarsContext = new StarWarsContext(options, dbLogger.Object);
            var repoLogger      = new Mock <ILogger <DroidRepository> >();

            _droidRepository = new DroidRepository(starWarsContext, repoLogger.Object);
        }
Beispiel #6
0
 public DroidRepositoryShould()
 {
     _droidRepository = new DroidRepository();
 }