コード例 #1
0
ファイル: UserLogicTests.cs プロジェクト: bevrand/bevrand
        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));
        }
コード例 #2
0
ファイル: UserLogicTests.cs プロジェクト: bevrand/bevrand
        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));
        }
コード例 #3
0
ファイル: UserLogicTests.cs プロジェクト: bevrand/bevrand
        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));
        }
コード例 #4
0
ファイル: UserLogicTests.cs プロジェクト: bevrand/bevrand
        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));
        }