Beispiel #1
0
        public void CreateAUserWithNullsDoesNotGetCreated(string user, string email, string password)
        {
            var mock = new Mock <IUserRepository>();

            var postModel = new PostUserModel
            {
                UserName     = user,
                EmailAddress = email,
                Active       = true,
                PassWord     = password
            };

            var service = new UsersLogic(mock.Object);

            Assert.Throws <ArgumentException>(() => service.CreateANewUser(postModel));
        }
Beispiel #2
0
        public void CreateANewUserWithAllFieldsGetsAdded()
        {
            var mock     = new Mock <IUserRepository>();
            var username = "******";
            var password = "******";
            var email    = "*****@*****.**";

            var postModel = new PostUserModel
            {
                UserName     = username,
                EmailAddress = email,
                Active       = true,
                PassWord     = password
            };

            var service = new UsersLogic(mock.Object);

            service.CreateANewUser(postModel);
            mock.Verify(x => x.Add(It.IsAny <UserModel>()), Times.Exactly(1));
        }
Beispiel #3
0
        public void CreateANewUserWithEmailThatDoesExistThrowsArgumentException()
        {
            var mock     = new Mock <IUserRepository>();
            var username = "******";
            var password = "******";
            var email    = "*****@*****.**";

            var postModel = new PostUserModel
            {
                UserName     = username,
                EmailAddress = email,
                Active       = true,
                PassWord     = password
            };

            mock.Setup(e => e.CheckIfEmailExists(email)).Returns(true);

            var service = new UsersLogic(mock.Object);

            Assert.Throws <ArgumentException>(() => service.CreateANewUser(postModel));
        }
Beispiel #4
0
        public void CreateANewEmailWithUserThatDoesNotExistPasses()
        {
            var mock     = new Mock <IUserRepository>();
            var username = "******";
            var password = "******";
            var email    = "*****@*****.**";

            var postModel = new PostUserModel
            {
                UserName     = username,
                EmailAddress = email,
                Active       = true,
                PassWord     = password
            };

            mock.Setup(e => e.CheckIfEmailExists(email)).Returns(false);

            var service = new UsersLogic(mock.Object);

            service.CreateANewUser(postModel);
            mock.Verify(x => x.Add(It.IsAny <UserModel>()), Times.Exactly(1));
        }