コード例 #1
0
        public void DeclineInvitation_GetDeclinedInvitation()
        {
            //Arrange
            var testUser   = new User("Petr", new Credentials("SomeEmail", "SomePassword"), true, UserType.User);
            var invitation = new Invitation(IntIterator.GetNextId(), testUser.Id, IntIterator.GetNextId(),
                                            MemberRole.Member, InvitationStatus.InProgress);

            testUser.AddInvitation(invitation);

            //Act
            testUser.DeclineInvitation(invitation.Id);

            //Assert
            Assert.AreEqual(InvitationStatus.Declined, testUser.Invitations[0].Status);
        }
コード例 #2
0
        public void CheckIfGroupContainsNotExistingTags_GetFalse()
        {
            //Arrange
            var group = new Group(IntIterator.GetNextId(), "SomeGroup", new List <string> {
                "c#", "c++", "js"
            },
                                  "The best", 1, 0, false, GroupType.Seminar);

            //Act
            var expected = false;
            var actual   = group.DoesContainsTags(new List <string> {
                "c++", "ada"
            });

            //Assert
            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void AddInvitation_GetRightListOfInvitations()
        {
            //Arrange
            var group = new Group(IntIterator.GetNextId(), "SomeGroup", new List <string> {
                "c#"
            },
                                  "The best", 1, 0, false, GroupType.Seminar);
            var invitation = new Invitation(IntIterator.GetNextId(), IntIterator.GetNextId(), group.GroupInfo.Id,
                                            MemberRole.Member, InvitationStatus.InProgress);

            //Act
            group.AddInvitation(invitation);

            //Assert
            Assert.AreEqual(1, group.Invitations.Count);
            Assert.AreEqual(invitation, group.Invitations[0]);
        }
コード例 #4
0
        public void AddUserToGroup_UserWasAddedToGroup()
        {
            //Arrange
            var creatorId     = IntIterator.GetNextId();
            var invitedUserId = IntIterator.GetNextId();
            var someGroup     = new Group(creatorId, "SomeGroup", new List <string> {
                "c#"
            },
                                          "The best", 3, 0, false, GroupType.Seminar);

            //Act
            someGroup.AddMember(invitedUserId);
            var expectedQuantity = 2;
            var actualQuantity   = someGroup.Members.Count;

            //Assert
            Assert.AreEqual(expectedQuantity, actualQuantity);
        }
コード例 #5
0
        public void Update(User user)
        {
            if (user == null)
            {
                throw new ArgumentNullException();
            }
            var currentUser = _listOfUsers.Find(current => current.Id == user.Id) ??
                              throw new UserNotFoundException(user.Id);

            currentUser.Invitations.ForEach(inv =>
            {
                if (inv.Id == 0)
                {
                    inv.Id = IntIterator.GetNextId();
                }
            });
            currentUser = user;
        }
コード例 #6
0
        public void DeleteYourselfFromGroup_ToBeDeleted()
        {
            //Arrange
            var creatorId     = IntIterator.GetNextId();
            var invitedUserId = IntIterator.GetNextId();
            var someGroup     = new Group(creatorId, "SomeGroup", new List <string> {
                "c#"
            },
                                          "The best", 3, 0, false, GroupType.Seminar);

            //Act
            someGroup.AddMember(invitedUserId);
            someGroup.DeleteMember(invitedUserId, invitedUserId);
            var expectedQuantity = 1;
            var resultQuantity   = someGroup.Members.Count;

            //Assert
            Assert.AreEqual(expectedQuantity, resultQuantity);
        }
コード例 #7
0
        public void CreateGroupWithSomeData_GroupWasCreated()
        {
            //Arrange
            var creatorId   = IntIterator.GetNextId();
            var title       = "some group";
            var description = "some description";
            var tags        = new List <string> {
                "c#"
            };
            var size         = 3;
            var moneyPerUser = 100.0;

            //Act
            var someGroup = new Group(creatorId, title, tags, description, size, moneyPerUser, false,
                                      GroupType.Lecture);

            //Assert
            Assert.AreEqual(creatorId, someGroup.GetMember(creatorId).UserId);
        }
コード例 #8
0
        public void OfferCourseWithApprovedTeacher_GetOfferedCourse()
        {
            //Arrange
            var approvedTeacher = new User("Sergey", new Credentials("email", "password"), true, UserType.User);
            var creatorId       = IntIterator.GetNextId();
            var invitedUserId   = IntIterator.GetNextId();
            var group           = new Group(creatorId, "SomeGroup", new List <string> {
                "c#"
            },
                                            "The best", 2, 0, false, GroupType.Seminar);
            var expectedCurriculum = "Awesome course";

            //Act
            group.AddMember(invitedUserId);
            group.ApproveTeacher(approvedTeacher);
            group.OfferCurriculum(approvedTeacher.Id, expectedCurriculum);

            //Assert
            Assert.AreEqual(group.GroupInfo.Curriculum, expectedCurriculum);
        }
コード例 #9
0
        public void CommitChatSession_GetUpdatedChatHistory()
        {
            //Arrange
            var creatorId = IntIterator.GetNextId();
            var group     = new Group(creatorId, "SomeGroup", new List <string> {
                "c#"
            },
                                      "The best", 3, 0, false, GroupType.Seminar);

            var someMessages = new List <BaseMessage>
            {
                new UserMessage(creatorId, "message1"),
                new UserMessage(creatorId, "message2"),
                new UserMessage(creatorId, "message3")
            };

            //Act
            group.CommitChatSession(someMessages);

            //Assert
            Assert.AreEqual(true, someMessages.SequenceEqual(group.Messages));
        }
コード例 #10
0
        public void CreatorLeftTheGroup_MemberBecameCreator()
        {
            //Arrange
            var creatorId     = IntIterator.GetNextId();
            var invitedUserId = IntIterator.GetNextId();
            var someGroup     = new Group(creatorId, "SomeGroup", new List <string> {
                "c#"
            },
                                          "The best", 3, 0, false, GroupType.Seminar);

            //Act
            someGroup.AddMember(invitedUserId);
            someGroup.DeleteMember(creatorId, creatorId);

            var expectedRole     = MemberRole.Creator;
            var expectedQuantity = 1;
            var resultRole       = someGroup.Members[0].MemberRole;
            var resultLength     = someGroup.Members.Count;

            //Assert
            Assert.AreEqual(expectedRole, resultRole);
            Assert.AreEqual(expectedQuantity, resultLength);
        }
コード例 #11
0
 public void AddKey(Key key)
 {
     Ensure.Any.IsNotNull(key);
     keyList.Add(key);
     key.Value = IntIterator.GetNextId();
 }
コード例 #12
0
 public void Add(Group group)
 {
     Ensure.Any.IsNotNull(group);
     group.GroupInfo.Id = IntIterator.GetNextId();
     _listOfGroups.Add(group);
 }
コード例 #13
0
        public void TryToAddInvitationWithWrongReceiverToUser_GetException()
        {
            //Arrange
            var testUser   = new User("Petr", new Credentials("SomeEmail", "SomePassword"), true, UserType.User);
            var invitation = new Invitation(IntIterator.GetNextId(), IntIterator.GetNextId(), IntIterator.GetNextId(),
                                            MemberRole.Member, InvitationStatus.InProgress);

            //Act
            testUser.AddInvitation(invitation);
        }