public void RegisterUser_ShortUsername_False() { var options = new DbContextOptionsBuilder <Mystivate_dbContext>() .UseInMemoryDatabase(databaseName: "RegisterUser_ShortUsername_False") .Options; using (var context = new Mystivate_dbContext(options)) { IAccountAccess accountAccess = new AccountAccess(context); IRegisterService registerService = new SignInService(null, accountAccess); string username = "******"; string email = "*****@*****.**"; string password = "******"; RegisterResult result = registerService.RegisterUser(new RegisterModel { Email = email, Username = username, Password = password }); Assert.AreEqual(RegisterResult.UsernameShort, result); } }
public void AddDailyTask_NonExistantUser_False() { var options = new DbContextOptionsBuilder <Mystivate_dbContext>() .UseInMemoryDatabase(databaseName: "AddDailyTask_NonExistantUser_True") .Options; using (var context = new Mystivate_dbContext(options)) { int taskId = AddDailyTask(new TaskAccess(context), 0, "Normal task"); Assert.IsFalse(DailyTaskExists(context, taskId)); } }
public void Initialize() { var host = new WebHostBuilder() .UseEnvironment("Development") .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup <TestStartup>(); TestServer server = new TestServer(host); dbContext = (Mystivate_dbContext)server.Host.Services.GetService(typeof(Mystivate_dbContext)); client = server.CreateClient(); }
public void AddTodo_NormalName_True() { var options = new DbContextOptionsBuilder <Mystivate_dbContext>() .UseInMemoryDatabase(databaseName: "AddTodo_NormalName_True") .Options; using (var context = new Mystivate_dbContext(options)) { IAccountAccess accountAccess = new AccountAccess(context); string email = "*****@*****.**"; UserTestsMethods.RegisterUser(accountAccess, "test", email, "test123"); int taskId = AddTodo(new TaskAccess(context), UserTestsMethods.GetUserId(accountAccess, email), "Normal task"); Assert.IsTrue(ToDoExists(context, taskId)); } }
public void RegisterUser_TwoSameUsernameEmail_False() { var options = new DbContextOptionsBuilder <Mystivate_dbContext>() .UseInMemoryDatabase(databaseName: "RegisterUser_TwoSameUsernameEmail_False") .Options; using (var context = new Mystivate_dbContext(options)) { IAccountAccess accountAccess = new AccountAccess(context); string username = "******"; string email = "*****@*****.**"; string password = "******"; Assert.IsTrue(UserTestsMethods.RegisterUser(accountAccess, username, email, password)); Assert.IsFalse(UserTestsMethods.RegisterUser(accountAccess, username, email, password)); } }
public void LoginUser_CorrectCredentials_True() { var options = new DbContextOptionsBuilder <Mystivate_dbContext>() .UseInMemoryDatabase(databaseName: "LoginUser_CorrectCredentials_True") .Options; using (var context = new Mystivate_dbContext(options)) { IAccountAccess accountAccess = new AccountAccess(context); string username = "******"; string email = "*****@*****.**"; string password = "******"; Assert.IsTrue(UserTestsMethods.RegisterUser(accountAccess, username, email, password)); EncryptedPassword encryptedPasswordDB = UserTestsMethods.GetPassword(accountAccess, email); Assert.IsTrue(PasswordEncryptor.PasswordCorrect(password, encryptedPasswordDB)); } }
public TaskAccess(Mystivate_dbContext db) { _dbContext = db; }
public static bool UserRegistered(Mystivate_dbContext context, string username, string email) { return(context.Users.SingleOrDefault(u => u.Username == username && u.Email == email) != null); }
public InventoryAccess(Mystivate_dbContext db) { _dbContext = db; }
public QuestAccess(Mystivate_dbContext db) { _dbContext = db; }
public AccountAccess(Mystivate_dbContext db) { _dbContext = db; }
public CharacterAccess(Mystivate_dbContext db) { _dbContext = db; }
public EquipmentAccess(Mystivate_dbContext db) { _dbContext = db; }
private bool ToDoExists(Mystivate_dbContext dbContext, int taskId) { return(dbContext.ToDos.SingleOrDefault(t => t.Id == taskId) != null); }
private bool DailyTaskExists(Mystivate_dbContext dbContext, int taskId) { return(dbContext.DailyTasks.SingleOrDefault(t => t.Id == taskId) != null); }