public void CreateAssignmentTest() { var options = new DbContextOptionsBuilder <AppDBContext>() .UseInMemoryDatabase(databaseName: "AssignmentCreateDatabase") .Options; using (var context = new AppDBContext(options)) { context.Assignment.Add(new Assignment { Id = "1", Name = "1", Description = "1" }); context.Assignment.Add(new Assignment { Id = "2", Name = "2", Description = "2" }); context.Assignment.Add(new Assignment { Id = "3", Name = "3", Description = "3" }); context.SaveChanges(); } using (var context = new AppDBContext(options)) { AssignmentRepository assignmentRepository = new AssignmentRepository(context); assignmentRepository.Create(new Assignment { Id = "4", Name = "4", Description = "4" }); context.SaveChanges(); List <Assignment> assignments = assignmentRepository.GetAll().ToList(); Assert.Equal(4, assignments.Count); } }