Example #1
0
        public void GetAllActiveSanctions_GetRightList()
        {
            //Arrange
            var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);

            var user1 = _accountFacade.RegUser("not admin", Credentials.FromRawData("*****@*****.**", "password"),
                                               false);
            var user2 = _accountFacade.RegUser("not admin", Credentials.FromRawData("*****@*****.**", "password"),
                                               false);
            var user3 = _accountFacade.RegUser("not admin", Credentials.FromRawData("*****@*****.**", "password"),
                                               false);

            sanctionFacade.AddSanction("some rule", user1, _adminId, SanctionType.NotAllowToJoinGroup);
            sanctionFacade.AddSanction("some rule", user2, _adminId, SanctionType.NotAllowToEditProfile);
            var canceledSanctionId =
                sanctionFacade.AddSanction("some rule", user3, _adminId, SanctionType.NotAllowToTeach);

            sanctionFacade.CancelSanction(canceledSanctionId);

            //Act
            var actual = sanctionFacade.GetAllActive().ToList();

            //Assert
            Assert.AreEqual(user1, actual[0].UserId);
            Assert.AreEqual(user2, actual[1].UserId);
        }
Example #2
0
        public void TryToAddSanctionToNotExistingUser_GetException()
        {
            //Arrange
            var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);

            //Act
            sanctionFacade.AddSanction("some rule", IntIterator.GetNextId(), _adminId,
                                       SanctionType.NotAllowToEditProfile);
        }
Example #3
0
        public void TryToAddSanctionWithInvalidExpirationDate_GetException()
        {
            //Arrange
            var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);

            //Act
            sanctionFacade.AddSanction("Some rule", _testUserId, _adminId,
                                       SanctionType.NotAllowToEditProfile, DateTimeOffset.Now);
        }
Example #4
0
        public void TryToBecomeTeacherWithSanctions_GetException()
        {
            //Arrange
            var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);

            sanctionFacade.AddSanction("some rule", _testUserId, _adminId, SanctionType.NotAllowToTeach);

            //Act
            _userEditFacade.BecomeTeacher(_testUserId);
        }
Example #5
0
        public void TryToEditBirthYearWithSanctions_GetException()
        {
            //Arrange
            var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);

            sanctionFacade.AddSanction("some rule", _testUserId, _adminId, SanctionType.NotAllowToEditProfile);

            //Act
            _userEditFacade.EditBirthYear(_testUserId, DateTimeOffset.UtcNow);
        }
Example #6
0
        public void TryToEditAvatarLinkWithSanctions_GetException()
        {
            //Arrange
            var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);

            sanctionFacade.AddSanction("some rule", _testUserId, _adminId, SanctionType.NotAllowToEditProfile);

            //Act
            _userEditFacade.EditAvatarLink(_testUserId, "new");
        }
Example #7
0
        public void TryToAddSanctionByNotModerator_GetException()
        {
            //Arrange
            var sanctionFacade  = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);
            var pseudoModerator = _accountFacade.RegUser("not admin",
                                                         Credentials.FromRawData("*****@*****.**", "password"), false);

            //Act
            sanctionFacade.AddSanction("some rule", _testUserId, pseudoModerator, SanctionType.NotAllowToEditProfile);
        }
Example #8
0
        public void AddSanction_GetAddedSanction()
        {
            //Arrange
            var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);

            //Act
            sanctionFacade.AddSanction("Some rule", _testUserId, _adminId, SanctionType.NotAllowToEditProfile);

            //Assert
            Assert.AreEqual(1, sanctionFacade.GetAll().ToList().Count);
        }
Example #9
0
        public void TryToEditContactsWithSanctions_GetException()
        {
            //Arrange
            var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);

            sanctionFacade.AddSanction("some rule", _testUserId, _adminId, SanctionType.NotAllowToEditProfile);

            //Act
            _userEditFacade.EditContacts(_testUserId, new List <string> {
                "new"
            });
        }
Example #10
0
        public void GetAllActiveSanctionsOfUser_GetRightResult()
        {
            //Arrange
            var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);

            var sanctionId1 =
                sanctionFacade.AddSanction("Some rule", _testUserId, _adminId, SanctionType.NotAllowToEditProfile);
            var sanctionId2 =
                sanctionFacade.AddSanction("Some rule", _testUserId, _adminId, SanctionType.NotAllowToEditProfile);
            var sanctionId3 =
                sanctionFacade.AddSanction("Some rule", _testUserId, _adminId, SanctionType.NotAllowToEditProfile);

            sanctionFacade.CancelSanction(sanctionId3);

            //Act
            var result = sanctionFacade.GetAllActiveOfUser(_testUserId).ToList();

            //Assert
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(sanctionId1, result[0].Id);
            Assert.AreEqual(sanctionId2, result[1].Id);
        }
Example #11
0
        public void CheckActivityOfExpiredSanction_GetInactiveSanction()
        {
            //Arrange
            var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);
            var sanctionId     = sanctionFacade.AddSanction("Some rule", _testUserId, _adminId,
                                                            SanctionType.NotAllowToEditProfile, DateTimeOffset.Now.AddMilliseconds(1));

            //Act
            Thread.Sleep(4);

            //Assert
            Assert.AreEqual(false, sanctionFacade.GetAll().ToList()[0].IsActive);
        }
Example #12
0
        public void CancelSanction_GetCanceledSanction()
        {
            //Arrange
            var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);
            var sanctionId     =
                sanctionFacade.AddSanction("some rule", _testUserId, _adminId, SanctionType.NotAllowToEditProfile);

            //Act
            sanctionFacade.CancelSanction(sanctionId);

            //Assert
            Assert.AreEqual(false, _sanctionRepository.Get(sanctionId).IsActive);
        }