Exemplo n.º 1
0
        public void TryToInviteTeacherToGroupWithApprovedTeacher_GetException()
        {
            //Arrange
            var publisher   = new Mock <IEventPublisher>();
            var groupFacade = new GroupFacade(_groupRepository, _userRepository, _sanctionRepository,
                                              new GroupSettings(1, 100, 0, 1000), publisher.Object);
            var accountFacade = new AccountFacade(_keysRepository,
                                                  _userRepository, _emailSender.Object, userSettings);
            var userFacade = new UserFacade(_userRepository, _groupRepository, _eventRepository, _publisher.Object);

            var creatorId        = accountFacade.RegUser("Creator", new Credentials("email1", "password"), false);
            var teacherId        = accountFacade.RegUser("Teacher", new Credentials("email2", "password"), true);
            var anotherTeacherId =
                accountFacade.RegUser("Another teacher", new Credentials("email3", "password"), true);

            var createdGroupId = groupFacade.CreateGroup(creatorId, "Some group", new List <string> {
                "c#"
            },
                                                         "Very interesting", 1, 100, false, GroupType.Lecture);
            var createdGroup = groupFacade.GetGroup(createdGroupId, creatorId);

            groupFacade.ApproveTeacher(userFacade.GetUser(teacherId).Id, createdGroupId);

            //Act
            userFacade.Invite(creatorId, anotherTeacherId, createdGroupId, MemberRole.Teacher);
        }
Exemplo n.º 2
0
        public void TryToGetAllGroupsOfUser_ReturnRightResult()
        {
            //Arrange
            var accountFacade = new AccountFacade(_keysRepository,
                                                  _userRepository, _emailSender.Object, userSettings);
            var userFacade  = new UserFacade(_userRepository, _groupRepository, _eventRepository, _publisher.Object);
            var publisher   = new Mock <IEventPublisher>();
            var groupFacade = new GroupFacade(_groupRepository, _userRepository, _sanctionRepository,
                                              new GroupSettings(2, 10, 0, 100), publisher.Object);

            var testUserId =
                accountFacade.RegUser("Alena", new Credentials("email1", "password"), true);
            var creatorId = accountFacade.RegUser("Galya", new Credentials("email2", "password"), true);

            var createdGroupId1 = groupFacade.CreateGroup(creatorId, "Group1", new List <string> {
                "c#"
            }, "Good group", 5,
                                                          0, false, GroupType.MasterClass);
            var createdGroupId2 = groupFacade.CreateGroup(creatorId, "Group2", new List <string> {
                "c#"
            },
                                                          "The best group!", 7, 0, true, GroupType.Seminar);

            var createdGroup1 = groupFacade.GetGroup(createdGroupId1, creatorId);
            var createdGroup2 = groupFacade.GetGroup(createdGroupId2, creatorId);

            //Act
            groupFacade.AddMember(createdGroup1.GroupInfoView.GroupId, testUserId);
            groupFacade.AddMember(createdGroup2.GroupInfoView.GroupId, testUserId);
            var expected = new List <FullGroupView> {
                createdGroup1, createdGroup2
            };
            var groups = userFacade.GetAllGroupsOfUser(testUserId).ToList();

            //Assert
            Assert.AreEqual(groups.Count, expected.Count);
        }