Beispiel #1
0
        public void AddUserWithSameUserName()
        {
            var newUser = new UserAccount()
            {
                UserName = "******", Password = "******"
            };

            try
            {
                manger.AddUser("Nasar3", "helloworld123");
                Assert.AreNotEqual("Nasar3", newUser.UserName);
            }
            catch (Exception error)
            {
                var table = Sql.SelectQuery("select * from getuser(@UserName)", newUser);
                var user  = ObjectConverter.ConvertDataTableRowToObject <UserAccount>(table, 0);
                Sql.AlterDataQuery("delete from useraccount where id = @Id", user);
                Assert.AreEqual("23505: duplicate key value violates unique constraint \"username\"", error.Message);
            }
        }