Beispiel #1
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);
        }
Beispiel #2
0
        public void Initialize()
        {
            var inMemoryUserRepository     = new InMemoryUserRepository();
            var inMemoryGroupRepository    = new InMemoryGroupRepository();
            var inMemoryKeyRepository      = new InMemoryKeysRepository();
            var inMemorySanctionRepository = new InMemorySanctionRepository();
            var inMemoryEventRepository    = new InMemoryEventRepository();
            var groupSettings = new GroupSettings(2, 10, 0, 1000);
            var emailSender   = new Mock <IEmailSender>();
            var publisher     = new Mock <IEventPublisher>();

            userSettings = new UserSettings("");

            var adminKey = new Key("email", KeyAppointment.BecomeAdmin);

            inMemoryKeyRepository.AddKey(adminKey);

            _sanctionFacade = new SanctionFacade(inMemorySanctionRepository, inMemoryUserRepository, publisher.Object);
            _groupFacade    = new GroupFacade(inMemoryGroupRepository, inMemoryUserRepository, inMemorySanctionRepository,
                                              new GroupSettings(3, 100, 0, 1000), publisher.Object);
            _userFacade = new UserFacade(inMemoryUserRepository, inMemoryGroupRepository, inMemoryEventRepository,
                                         publisher.Object);
            _accountFacade = new AccountFacade(inMemoryKeyRepository, inMemoryUserRepository,
                                               emailSender.Object, userSettings);
            var creatorId = _accountFacade.RegUser("Alena", new Credentials("email", "password"), true, adminKey.Value);

            _groupCreator = _userFacade.GetUser(creatorId);
        }
Beispiel #3
0
        public void CreateGroupByGroupFacadeWithValidValues_GroupWasCreated()
        {
            //Arrange
            var creatorId   = _accountFacade.RegUser("Alena", Credentials.FromRawData("Email", "Password"), false);
            var title       = "some group";
            var description = "some description";
            var tags        = new List <string> {
                "c#"
            };
            var size         = 3;
            var moneyPerUser = 100.0;

            //Act
            var groupId = _groupFacade.CreateGroup(creatorId, title, tags, description, size, moneyPerUser,
                                                   false, GroupType.Seminar);

            //Assert
            Assert.IsNotNull(_groupFacade.GetGroup(groupId, creatorId));
        }
        public IActionResult Registrate([FromBody] RegistrationRequest request)
        {
            int newId;

            if (!request.InviteCode.Equals(0))
            {
                newId = _userAccountFacade.RegUser(request.Name,
                                                   Credentials.FromRawData(request.Email.ToLower(), request.Password),
                                                   request.IsTeacher, request.InviteCode);
            }
            else
            {
                newId = _userAccountFacade.RegUser(request.Name,
                                                   Credentials.FromRawData(request.Email.ToLower(), request.Password),
                                                   request.IsTeacher);
            }

            var response = new RegistrationResponse(newId);

            return(Ok(response));
        }
Beispiel #5
0
        public void Initialize()
        {
            var emailSender     = new Mock <IEmailSender>();
            var keysRepository  = new InMemoryKeysRepository();
            var groupRepository = new InMemoryGroupRepository();
            var fileRepository  = new InMemoryFileRepository();
            var eventRepository = new InMemoryEventRepository();
            var adminKey        = new Key("*****@*****.**", KeyAppointment.BecomeAdmin);

            keysRepository.AddKey(adminKey);
            userSettings = new UserSettings("");

            _publisher          = new Mock <IEventPublisher>();
            _userRepository     = new InMemoryUserRepository();
            _sanctionRepository = new InMemorySanctionRepository();
            _accountFacade      = new AccountFacade(keysRepository, _userRepository, emailSender.Object, userSettings);
            _userFacade         = new UserFacade(_userRepository, groupRepository, eventRepository, _publisher.Object);
            _adminId            = _accountFacade.RegUser("Ivan", Credentials.FromRawData("*****@*****.**", "1"), false,
                                                         adminKey.Value);
            _testUserId = _accountFacade.RegUser("Sasha", Credentials.FromRawData("*****@*****.**", "2"), false);
        }
        public void TryToChangeGroupSizeWithValueThatLessThanMembersCount_GetException()
        {
            //Arrange
            var createdGroupId = _groupFacade.CreateGroup(_groupCreatorId, "Some group", new List <string> {
                "c#"
            },
                                                          "You're welcome!", 2, 100, false, GroupType.Lecture);
            var memberId = _accountFacade.RegUser("member", Credentials.FromRawData("email", "password"), true);

            _groupFacade.AddMember(createdGroupId, memberId);

            //Act
            _groupEditFacade.ChangeGroupSize(createdGroupId, _groupCreatorId, 1);
        }
        public void Initialize()
        {
            var inMemoryUserRepository     = new InMemoryUserRepository();
            var inMemoryGroupRepository    = new InMemoryGroupRepository();
            var inMemoryKeyRepository      = new InMemoryKeysRepository();
            var inMemorySanctionRepository = new InMemorySanctionRepository();
            var groupSettings = new GroupSettings(2, 10, 0, 1000);
            var emailSender   = new Mock <IEmailSender>();
            var publisher     = new Mock <IEventPublisher>();

            userSettings = new UserSettings("");

            _groupFacade = new GroupFacade(inMemoryGroupRepository, inMemoryUserRepository, inMemorySanctionRepository,
                                           new GroupSettings(3, 100, 0, 1000), publisher.Object);
            _accountFacade = new AccountFacade(inMemoryKeyRepository, inMemoryUserRepository,
                                               emailSender.Object, userSettings);
            _groupEditFacade = new GroupEditFacade(inMemoryGroupRepository, groupSettings, publisher.Object);
            _groupCreatorId  =
                _accountFacade.RegUser("Alena", new Credentials("email", "password"), true);
        }