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);
            }
        }
Esempio n. 2
0
        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));
            }
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        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));
            }
        }
Esempio n. 5
0
        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));
            }
        }
Esempio n. 6
0
        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));
            }
        }
Esempio n. 7
0
 public TaskAccess(Mystivate_dbContext db)
 {
     _dbContext = db;
 }
Esempio n. 8
0
 public static bool UserRegistered(Mystivate_dbContext context, string username, string email)
 {
     return(context.Users.SingleOrDefault(u => u.Username == username && u.Email == email) != null);
 }
Esempio n. 9
0
 public InventoryAccess(Mystivate_dbContext db)
 {
     _dbContext = db;
 }
Esempio n. 10
0
 public QuestAccess(Mystivate_dbContext db)
 {
     _dbContext = db;
 }
Esempio n. 11
0
 public AccountAccess(Mystivate_dbContext db)
 {
     _dbContext = db;
 }
Esempio n. 12
0
 public CharacterAccess(Mystivate_dbContext db)
 {
     _dbContext = db;
 }
Esempio n. 13
0
 public EquipmentAccess(Mystivate_dbContext db)
 {
     _dbContext = db;
 }
Esempio n. 14
0
 private bool ToDoExists(Mystivate_dbContext dbContext, int taskId)
 {
     return(dbContext.ToDos.SingleOrDefault(t => t.Id == taskId) != null);
 }
Esempio n. 15
0
 private bool DailyTaskExists(Mystivate_dbContext dbContext, int taskId)
 {
     return(dbContext.DailyTasks.SingleOrDefault(t => t.Id == taskId) != null);
 }