Exemplo n.º 1
0
 public void Remove(IntIterator iter)
 {
     while (iter.HasNext())
     {
         Remove(iter.Next());
     }
 }
Exemplo n.º 2
0
 public void Add(IntIterator iter)
 {
     while (iter.HasNext())
     {
         Add(iter.Next());
     }
 }
Exemplo n.º 3
0
        public void StartCourseWithApprovedTeacherAndAllReadyMembers_CourseWasStarted()
        {
            //Arrange
            var approvedTeacher = new User("Sergey", new Credentials("email", "password"), true, UserType.User);
            var creatorId       = IntIterator.GetNextId();
            var user1Id         = IntIterator.GetNextId();
            var user2Id         = IntIterator.GetNextId();
            var group           = new Group(creatorId, "SomeGroup", new List <string> {
                "c#"
            },
                                            "The best", 3, 0, false, GroupType.Seminar);
            var expectedCurriculum = "Awesome course";

            //Act
            group.AddMember(user1Id);
            group.AddMember(user2Id);
            group.ApproveTeacher(approvedTeacher);
            group.OfferCurriculum(approvedTeacher.Id, expectedCurriculum);
            group.AcceptCurriculum(creatorId);
            group.AcceptCurriculum(user1Id);
            group.AcceptCurriculum(user2Id);

            //Assert
            Assert.AreEqual(group.Status, CourseStatus.Started);
        }
Exemplo n.º 4
0
        public bool Equals_obj(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            if (!(obj is IntSet))
            {
                return(false);
            }

            IntSet set = (IntSet)obj;

            IntIterator a = this.Iterator();
            IntIterator b = set.Iterator();

            while (a.HasNext() && b.HasNext())
            {
                if (a.Next() != b.Next())
                {
                    return(false);
                }
            }

            if (a.HasNext() || b.HasNext())
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
 public void Add(IntIterator indices)
 {
     while (indices.HasNext())
     {
         bitset.Set(indices.Next(), true);
     }
 }
Exemplo n.º 6
0
        public void CancelNotExistingSanction_GetException()
        {
            //Arrange
            var sanctionFacade = new SanctionFacade(_sanctionRepository, _userRepository, _publisher.Object);

            //Act
            sanctionFacade.CancelSanction(IntIterator.GetNextId());
        }
 public void Add(Sanction sanction)
 {
     if (sanction == null)
     {
         throw new ArgumentNullException();
     }
     sanction.Id = IntIterator.GetNextId();
     _listOfSanctions.Add(sanction);
 }
 public void AddEvent(Event @event)
 {
     if (@event == null)
     {
         throw new ArgumentNullException();
     }
     @event.Id = IntIterator.GetNextId();
     _events.Add(@event);
 }
Exemplo n.º 9
0
        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 Add(User user)
 {
     if (user == null)
     {
         throw new ArgumentNullException();
     }
     user.Id = IntIterator.GetNextId();
     _listOfUsers.Add(user);
 }
Exemplo n.º 11
0
 public override void Close()
 {
     if (!MandatoryKeys.Empty)
     {
         for (IntIterator key = MandatoryKeys.intIterator(); key.hasNext();)
         {
             Reporter.report(Record, ReportClass, RecordType).missingMandatoryProperty(key.next());
         }
     }
 }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        public void TryToAddNotExistingUserToGroup_GetException()
        {
            //Arrange
            var createdGroupId = _groupFacade.CreateGroup(_groupCreator.Id, "Some group", new List <string> {
                "c#"
            },
                                                          "You're welcome!", 3, 20, false, GroupType.Lecture);

            //Act
            _groupFacade.AddMember(createdGroupId, IntIterator.GetNextId());
        }
Exemplo n.º 14
0
        public void TryToCreateGroupByNotExistingUser_GetException()
        {
            //Arrange
            var invalidUserId = IntIterator.GetNextId();

            //Act
            _groupFacade.CreateGroup(invalidUserId, "Some group", new List <string> {
                "c#"
            },
                                     "You're welcome!", 3, 100, false, GroupType.Lecture);
        }
Exemplo n.º 15
0
        public void TryToDeleteNotExistingMember_GetException()
        {
            //Arrange
            var creatorId = IntIterator.GetNextId();
            var someGroup = new Group(creatorId, "SomeGroup", new List <string> {
                "c#"
            },
                                      "The best", 3, 0, false, GroupType.Seminar);

            //Act
            someGroup.DeleteMember(creatorId, IntIterator.GetNextId());
        }
Exemplo n.º 16
0
        public void TryToAddUserToFullGroup_GetException()
        {
            //Arrange
            var creatorId = IntIterator.GetNextId();
            var someGroup = new Group(creatorId, "SomeGroup", new List <string> {
                "c#"
            },
                                      "The best", 1, 0, false, GroupType.Seminar);

            //Act
            someGroup.AddMember(IntIterator.GetNextId());
        }
Exemplo n.º 17
0
        public void TryToDeclineAlreadyDeclinedInvitation_GetException()
        {
            //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);
            testUser.DeclineInvitation(invitation.Id);

            //Act
            testUser.DeclineInvitation(invitation.Id);
        }
Exemplo n.º 18
0
        public void TryToDeleteWithNotEnoughtRights_GetException()
        {
            //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, creatorId);
        }
Exemplo n.º 19
0
        public void AddReviewToTeacher_GetAddedReview()
        {
            //Arrange
            var teacher = new User("Petr", new Credentials("SomeEmail", "SomePassword"), true, UserType.User);

            //Act
            var guid   = IntIterator.GetNextId();
            var review = new Review(guid, "The best", "The beast teacher of the year", guid);

            teacher.TeacherProfile.AddReview(guid, "The best", "The beast teacher of the year", guid);

            //Assert
            Assert.AreEqual(review.Text, teacher.TeacherProfile.Reviews.ToList()[0].Text);
        }
Exemplo n.º 20
0
        public void AddInvitationWithRightReceiverToUser_GetRightInvitationList()
        {
            //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);

            //Act
            testUser.AddInvitation(invitation);

            //Assert
            Assert.AreEqual(1, testUser.Invitations.Count);
            Assert.AreEqual(invitation, testUser.Invitations[0]);
        }
Exemplo n.º 21
0
        public void TryToApproveAnotherTeacherWithApprovedTeacher_GetException()
        {
            //Arrange
            var approvedTeacher = new User("Sergey", new Credentials("email", "password"), true, UserType.User);
            var newTeacher      = new User("Bogdan", new Credentials("email", "password"), true, UserType.User);
            var group           = new Group(IntIterator.GetNextId(), "SomeGroup", new List <string> {
                "c#"
            },
                                            "The best", 1, 0, false, GroupType.Seminar);

            //Act
            group.ApproveTeacher(approvedTeacher);
            group.ApproveTeacher(newTeacher);
        }
        public void Update(Group group)
        {
            Ensure.Any.IsNotNull(group);
            var currentGroup = _listOfGroups.Find(current => current.GroupInfo.Id == group.GroupInfo.Id) ??
                               throw new GroupNotFoundException(group.GroupInfo.Id);

            currentGroup.Messages.ToList().ForEach(msg =>
            {
                if (msg.Id == 0)
                {
                    msg.Id = IntIterator.GetNextId();
                }
            });
            currentGroup = group;
        }
Exemplo n.º 23
0
        public void ApproveTeacher_TeacherIsSet()
        {
            //Arrange
            var teacher = new User("Sergey", new Credentials("email", "password"), true, UserType.User);
            var group   = new Group(IntIterator.GetNextId(), "SomeGroup", new List <string> {
                "c#"
            },
                                    "The best", 1, 0, false, GroupType.Seminar);

            //Act
            group.ApproveTeacher(teacher);

            //Assert
            Assert.AreEqual(teacher, group.Teacher);
        }
Exemplo n.º 24
0
        private void LoadProperties(PropertyLoader propertyLoader, MutableIntSet additionalPropertiesToLoad, EntityType type)
        {
            _hasLoadedAdditionalProperties = true;
            propertyLoader.LoadProperties(_entityId, type, additionalPropertiesToLoad, this);

            // loadProperties removes loaded properties from the input set, so the remaining ones were not on the node
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.iterator.IntIterator propertiesWithNoValue = additionalPropertiesToLoad.intIterator();
            IntIterator propertiesWithNoValue = additionalPropertiesToLoad.intIterator();

            while (propertiesWithNoValue.hasNext())
            {
                Put(propertiesWithNoValue.next(), _noValue);
            }
        }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
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);
        }
Exemplo n.º 27
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]);
        }
Exemplo n.º 28
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;
        }
Exemplo n.º 30
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);
        }