Exemple #1
0
        [TestMethod]//ok
        public void UpdateUserTest()
        {
            //arrange
            var user = new Users
            {
                Nickname = Guid.NewGuid().ToString().Substring(10),
                Username = Guid.NewGuid().ToString().Substring(10),
                Info     = Guid.NewGuid().ToString().Substring(10)
            };
            var newuser = new Users
            {
                Nickname = Guid.NewGuid().ToString().Substring(10),
                Username = Guid.NewGuid().ToString().Substring(10),
                Info     = Guid.NewGuid().ToString().Substring(10)
            };
            var dataLayer = new DataLayer.Sql.DataLayer(ConnectionString);

            //act
            user = dataLayer.AddUser(user);
            dataLayer.UpdateUser(user.UserId, newuser);
            //asserts
            var resultUser = dataLayer.GetUser(user.UserId);

            Assert.AreEqual(user.UserId, resultUser.UserId);
        }
        public void ShouldNotGetUser()
        {
            //arrange
            var user = GenerateUser();

            //act
            var dataLayer = new DataLayer.Sql.DataLayer(ConnectionSql);

            user = dataLayer.GetUser(user.Id);

            //assert
            Assert.AreEqual(user.Id, Guid.Empty);
        }
        public void ShouldAddUser()
        {
            //arrange
            var user = GenerateUser();

            //act
            var dataLayer = new DataLayer.Sql.DataLayer(ConnectionSql);

            dataLayer.AddUser(user);
            var resUser = dataLayer.GetUser(user.Id);

            //assert
            Assert.AreEqual(resUser.Id, user.Id);
        }
        public void ShouldAddUser()
        {
            //arrange
            var user = new User
            {
                Name = Guid.NewGuid().ToString().Substring(10)
            };
            var dataLayer = new DataLayer.Sql.DataLayer(ConnectionString);

            //act
            user = dataLayer.AddUser(user);
            //asserts
            var resultUser = dataLayer.GetUser(user.Id);

            Assert.AreEqual(user.Name, resultUser.Name);
        }
Exemple #5
0
        [TestMethod]//ok
        public void GetUserTest()
        {
            var user = new Users
            {
                UserId   = Guid.NewGuid(),
                Nickname = Guid.NewGuid().ToString().Substring(10),
                Username = Guid.NewGuid().ToString().Substring(10),
                Info     = Guid.NewGuid().ToString().Substring(10)
            };
            //act
            var dataLayer = new DataLayer.Sql.DataLayer(ConnectionString);

            user = dataLayer.AddUser(user);
            //asserts
            var resultUser = dataLayer.GetUser(user.UserId);

            Assert.AreEqual(user.Nickname, resultUser.Nickname);
        }
Exemple #6
0
        [TestMethod]//ok
        public void DeleteUserTest()
        {
            //arrange
            var user = new Users
            {
                //UserId = Guid.NewGuid(),
                Nickname = Guid.NewGuid().ToString().Substring(10),
                Username = Guid.NewGuid().ToString().Substring(10),
                Info     = Guid.NewGuid().ToString().Substring(10)
            };
            //act
            var dataLayer = new DataLayer.Sql.DataLayer(ConnectionString);

            user = dataLayer.AddUser(user);
            dataLayer.DeleteUser(user.UserId);
            var resultUser = dataLayer.GetUser(user.UserId);

            //asserts
            Assert.AreNotEqual(user.UserId, resultUser.UserId);
        }
        public void ShouldAddGetDeleteUser()
        {
            //arrange
            var user = new User
            {
                UserName = "******" /*Guid.NewGuid().ToString()*/
            };
            //act
            var dataLayer = new DataLayer.Sql.DataLayer(_connectionString);
            var addUser   = dataLayer.AddUser(user);

            var dataLayer1 = new DataLayer.Sql.DataLayer(_connectionString);
            var getUser    = dataLayer1.GetUser(addUser.UserId);

            var dataLayer2 = new DataLayer.Sql.DataLayer(_connectionString);
            var isDeleted  = dataLayer2.DeleteUser(getUser.UserId);

            //asserts
            Assert.AreEqual(addUser.UserId, getUser.UserId);
            Assert.AreEqual(addUser.UserName, getUser.UserName);
            Assert.IsNotNull(isDeleted);
        }