public void GetAll_WhenTwoExistingUsers_ExpectedResultAreEqual()
        {
            //Arrange
            var DALStub          = new AdminUserDALStub();
            var defaultAdminUser = new AdminUserModelDAL
            {
                Username       = "******",
                HashedPassword = PasswordHelperTool.PasswordSHA256Hasher("1234")
            };
            var newAdminUser = new AdminUserModelDAL
            {
                Username       = "******",
                HashedPassword = PasswordHelperTool.PasswordSHA256Hasher("newadmin")
            };
            bool successfullCreate = DALStub.Create(newAdminUser);
            var  expectedResult    = new List <AdminUserModelDAL>();

            expectedResult.Add(defaultAdminUser);
            expectedResult.Add(newAdminUser);

            //Act
            var result = DALStub.GetAll();

            //Assert
            Assert.IsTrue(expectedResult.Count == result.Count);
            for (int i = 0; i < result.Count; i++)
            {
                Assert.AreEqual(expectedResult[i].Username, result[i].Username);
            }
        }
        public void Delete_WhenTwoExistingUsers_ExpectedResultCount1()
        {
            //Arrange
            var DALStub          = new AdminUserDALStub();
            var defaultAdminUser = new AdminUserModelDAL
            {
                Username       = "******",
                HashedPassword = PasswordHelperTool.PasswordSHA256Hasher("1234")
            };
            var adminUserToDelete = new AdminUserModelDAL
            {
                Username       = "******",
                HashedPassword = PasswordHelperTool.PasswordSHA256Hasher("torspassword")
            };
            bool successfullCreate = DALStub.Create(adminUserToDelete);
            var  expectedResult    = new List <AdminUserModelDAL>();

            expectedResult.Add(defaultAdminUser);

            //Act
            bool successfullDelete = DALStub.Delete("tor");
            var  result            = DALStub.GetAll();

            //Assert
            Assert.IsTrue(successfullCreate);       // Here to make sure the test doesnt pass from it's target not existing
            Assert.IsTrue(successfullDelete);       // Test to se if Delete() is executed
            Assert.IsTrue(result.Count == 1);       // Test to se if Count is back to one
            for (int i = 0; i < result.Count; i++)  // Test to se if correct user has been deleted by comparing to expectations
            {
                Assert.AreEqual(expectedResult[i].Username, result[i].Username);
            }
        }
        public void Create_WhenEmptyUsername_ExpectedResultFalse()
        {
            //Arrange
            var DALStub = new AdminUserDALStub();
            var input   = new AdminUserModelDAL
            {
                Username       = "",
                HashedPassword = PasswordHelperTool.PasswordSHA256Hasher("password")
            };

            //Act
            bool test = DALStub.Create(input);

            //Assert
            Assert.IsFalse(test);
        }
        public void Create_WhenAllOK_ExpectedResultTrueAreEqual()
        {
            //Arrange
            var DALStub = new AdminUserDALStub();
            var input   = new AdminUserModelDAL
            {
                Username       = "******",
                HashedPassword = PasswordHelperTool.PasswordSHA256Hasher("password")
            };

            //Act
            bool test   = DALStub.Create(input);
            var  result = DALStub.Get("newadmin");

            //Assert
            Assert.IsTrue(test);
            Assert.AreEqual(input, result);
        }