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); }
public void TryToAddSanctionToNotExistingUser_GetException() { //Arrange var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object); //Act sanctionFacade.AddSanction("some rule", IntIterator.GetNextId(), _adminId, SanctionType.NotAllowToEditProfile); }
public void TryToAddSanctionWithInvalidExpirationDate_GetException() { //Arrange var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object); //Act sanctionFacade.AddSanction("Some rule", _testUserId, _adminId, SanctionType.NotAllowToEditProfile, DateTimeOffset.Now); }
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); }
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); }
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"); }
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); }
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); }
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" }); }
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); }
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); }
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); }