public void CreateAccount() { // 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); var oldValue = context.Users.Count(); var created = service.CreateAccount("florian", "admin3"); Assert.AreEqual(true, created); Assert.AreEqual(oldValue + 1, context.Users.Count()); } } finally { connection.Close(); } }
public bool CreateAccount(User user) { return(_groupRepository.CreateAccount(user.username, user.password)); }