public DatabaseInitializer( PetClinicDbContext db, IEnumerable <IInitialData> initialDataProviders) { this.db = db; this.initialDataProviders = initialDataProviders; }
public PetClinicDbContextSpecs() { this.dateTime = new DateTime(2020, 1, 1); var dateTimeMock = new Mock <IDateTime>(); dateTimeMock .SetupGet(dt => dt.Now) .Returns(this.dateTime); this.userId = "00000000-0000-0000-0000-000000000000"; var currentUserMock = new Mock <ICurrentUser>(); currentUserMock .Setup(m => m.UserId) .Returns(this.userId); var options = new DbContextOptionsBuilder <PetClinicDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var eventDispatcherMock = new Mock <IEventDispatcher>(); this.data = new PetClinicDbContext( options, eventDispatcherMock.Object, currentUserMock.Object, dateTimeMock.Object); this.data.Doctors.Add(new DbDoctor { UserId = this.userId, Name = "test name" }); this.data.SaveChanges(); }
protected DataRepository(PetClinicDbContext context) => this.Data = context;