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); }
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); }
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]); }
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); }
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; }
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); }
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); }
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); }
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)); }
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); }
public void AddKey(Key key) { Ensure.Any.IsNotNull(key); keyList.Add(key); key.Value = IntIterator.GetNextId(); }
public void Add(Group group) { Ensure.Any.IsNotNull(group); group.GroupInfo.Id = IntIterator.GetNextId(); _listOfGroups.Add(group); }
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); }