public void UserIsAlreadyBlocked()
        {
            _mockRepository
            .Setup(x => x.GetById(It.IsAny <int>()))
            .Returns(UserTestHelper.CreatBlockedUser(1));

            Assert.Throws(Is.TypeOf <OperationCanceledException>().And.Message.EqualTo("UserAlreadyBlocked"), () => _service.Block(1));
        }
        public void MustBeCreated()
        {
            var user = _service.RegisterUser(UserTestHelper.CreateUser(1));

            Assert.IsFalse(user.IsActive);
            Assert.IsFalse(user.IsBlocked);

            Assert.AreEqual("John123", user.UserName);
            Assert.AreEqual("*****@*****.**", user.Email);
        }
Exemplo n.º 3
0
        public void ShouldBeActiveAfterCreation()
        {
            _mockRepository
            .Setup(x => x.GetById(It.IsAny <int>()))
            .Returns(UserTestHelper.CreateUser(1));

            var user = _service.ActivateUser(1);

            Assert.IsTrue(user.IsActive);
            Assert.IsFalse(user.IsBlocked);
            Assert.AreEqual("John123", user.UserName);
            Assert.AreEqual("*****@*****.**", user.Email);
        }
        public void UsernameDoesNotHaveAllowedLength()
        {
            var user = UserTestHelper.CreateWrongUsername(1);

            Assert.Throws(Is.TypeOf <ArgumentException>().And.Message.EqualTo($"{user.UserName} too long"), () => _service.RegisterUser(UserTestHelper.CreateWrongUsername(1)));
        }
 public void EmailDoesNotMatchTheDomain()
 {
     Assert.Throws(Is.TypeOf <ArgumentException>().And.Message.EqualTo("InvalidMailDomain"), () => _service.RegisterUser(UserTestHelper.CreateWrongEmailUser(1)));
 }