示例#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);
        }
示例#2
0
        public void CancelNotExistingSanction_GetException()
        {
            //Arrange
            var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);

            //Act
            sanctionFacade.CancelSanction(IntIterator.GetNextId());
        }
示例#3
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);
        }
示例#4
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);
        }