コード例 #1
0
        public DatabaseFixture()
        {
            var options = new DbContextOptionsBuilder <KeepNoteContext>()
                          .UseInMemoryDatabase(databaseName: "NoteDB")
                          .Options;

            //Initializing DbContext with InMemory
            context = new KeepNoteContext(options);

            // Insert seed data into the database using one instance of the context
            context.Notes.Add(new Note {
                NoteTitle = "Technology", NoteContent = "ASP.NET Core", NoteStatus = "Completed"
            });
            context.SaveChanges();
            context.Notes.Add(new Note {
                NoteTitle = "Stack", NoteContent = "DOTNET", NoteStatus = "Started"
            });
            context.SaveChanges();
        }
コード例 #2
0
 public NoteRepository(KeepNoteContext KContext)
 {
     context = KContext;//dependency Injection
 }
コード例 #3
0
 public void Dispose()
 {
     context = null;
 }