public void AddTaskToUserStory() { // In-memory database only exists while the connection is open var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); try { var options = new DbContextOptionsBuilder <ScrumContext>() .UseSqlite(connection) .Options; // Create the schema in the database using (var context = new ScrumContext(options)) { context.Database.EnsureCreated(); } // Run the test against one instance of the context using (var context = new ScrumContext(options)) { var service = new GroupRepository(context); UserStory userStory = new UserStory("user story message", 3, 0, -1); userStory.storyId = 1; Tasks task = new Tasks("task message", 5); task.TaskId = 1; task.Completed = false; bool added = service.AddTaskToUserStory(task); Assert.AreEqual(true, added); Assert.AreEqual(1, context.Tasks.Count()); Assert.AreEqual("task message", context.Tasks.Find(1).TaskMessage); } } finally { connection.Close(); } }
public bool addTaskToUserStory(Tasks task) { return(_groupRepository.AddTaskToUserStory(task)); }