Example #1
0
        public virtual List <Company.Structures.ResponsibilitiesReport.ResponsibilitiesReportTableLine> GetResponsibilitiesReportData(IEmployee employee)
        {
            // HACK: Получаем отображаемое имя модуля.
            var moduleGuid     = new MeetingsModule().Id;
            var moduleName     = Sungero.Metadata.Services.MetadataSearcher.FindModuleMetadata(moduleGuid).GetDisplayName();
            var modulePriority = Company.PublicConstants.ResponsibilitiesReport.MeetingsPriority;
            var result         = new List <Company.Structures.ResponsibilitiesReport.ResponsibilitiesReportTableLine>();

            if (!Meetings.AccessRights.CanRead())
            {
                return(result);
            }

            var emplIsPresident = Meetings.GetAll(x => Equals(x.President, employee))
                                  .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active)
                                  .Where(d => d.DateTime >= Calendar.Now);

            result = Company.PublicFunctions.Module.AppendResponsibilitiesReportResult(result, emplIsPresident, moduleName, modulePriority,
                                                                                       Resources.MeetingsPresident, null);

            var emplIsSecretary = Meetings.GetAll(x => Equals(x.Secretary, employee))
                                  .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active)
                                  .Where(d => d.DateTime >= Calendar.Now);

            result = Company.PublicFunctions.Module.AppendResponsibilitiesReportResult(result, emplIsSecretary, moduleName, modulePriority,
                                                                                       Resources.MeetingsSecretary, null);

            return(result);
        }
Example #2
0
        public async Task AddReply_WhenDataIsValid_IsSuccessful()
        {
            // Arrange
            var meetingId = await MeetingHelper.CreateMeetingAsync(MeetingsModule, ExecutionContext);

            var meetingCommentId = await MeetingsModule.ExecuteCommandAsync(new AddMeetingCommentCommand(meetingId, "The meeting was great."));

            var date = new DateTime(2020, 1, 1, 01, 00, 00);

            SystemClock.Set(date);
            var reply = "Absolutely!";

            // Act
            var replyId = await MeetingsModule.ExecuteCommandAsync(new AddReplyToMeetingCommentCommand(meetingCommentId, reply));

            // Assert
            var meetingComments = await MeetingsModule.ExecuteQueryAsync(new GetMeetingCommentsQuery(meetingId));

            Assert.That(meetingComments.Count, Is.EqualTo(2));
            var commentReply = meetingComments.Single(c => c.Id == replyId);

            Assert.That(commentReply.InReplyToCommentId, Is.EqualTo(meetingCommentId));
            Assert.That(commentReply.Comment, Is.EqualTo(reply));
            Assert.That(commentReply.AuthorId, Is.EqualTo(ExecutionContext.UserId));
            Assert.That(commentReply.CreateDate, Is.EqualTo(date));
            Assert.That(commentReply.EditDate, Is.Null);
        }
        public async Task CreateNewMeetingGroup_Test()
        {
            // Arrange
            var proposalId = await MeetingsModule.ExecuteCommandAsync(new ProposeMeetingGroupCommand(
                                                                          MeetingGroupProposalSampleData.Name,
                                                                          MeetingGroupProposalSampleData.Description,
                                                                          MeetingGroupProposalSampleData.LocationCity,
                                                                          MeetingGroupProposalSampleData.LocationCountryCode));

            await MeetingsModule.ExecuteCommandAsync(new AcceptMeetingGroupProposalCommand(Guid.NewGuid(), proposalId));

            // Act
            await MeetingsModule.ExecuteCommandAsync(
                new CreateNewMeetingGroupCommand(
                    Guid.NewGuid(),
                    new MeetingGroupProposalId(proposalId)));

            // Assert
            var meetingGroups = await MeetingsModule.ExecuteQueryAsync(new GetAuthenticationMemberMeetingGroupsQuery());

            Assert.That(meetingGroups, Is.Not.Empty);

            var meetingGroupDetails =
                await MeetingsModule.ExecuteQueryAsync(new GetMeetingGroupDetailsQuery(proposalId));

            Assert.That(meetingGroupDetails.MembersCount, Is.EqualTo(1));
        }
        public async Task AddMeetingCommentLike_WhenDataIsValid_IsSuccess()
        {
            // Arrange
            await MeetingsModule.ExecuteCommandAsync(
                new CreateMemberCommand(
                    Guid.NewGuid(),
                    ExecutionContext.UserId,
                    "ivan_petrov",
                    "*****@*****.**",
                    "Ivan",
                    "Petrov",
                    "Ivan Petrov"));

            var meetingId = await MeetingHelper.CreateMeetingAsync(MeetingsModule, ExecutionContext);

            var meetingCommentId = await MeetingsModule.ExecuteCommandAsync(new AddMeetingCommentCommand(meetingId, "The meeting was awesome."));

            // Act
            await MeetingsModule.ExecuteCommandAsync(new AddMeetingCommentLikeCommand(meetingCommentId));

            // Assert
            var meetingCommentLikers = await MeetingsModule.ExecuteQueryAsync(new GetMeetingCommentLikersQuery(meetingCommentId));

            Assert.That(meetingCommentLikers.Count, Is.EqualTo(1));
            Assert.That(meetingCommentLikers.Single().Id, Is.EqualTo(ExecutionContext.UserId));

            await AssertEventually(
                new GetMeetingCommentsProbe(MeetingsModule, meetingId, meetingCommentId, expectedCommentLikesCount : 1),
                10000);
        }
Example #5
0
        public async Task EditMeetingComment_WhenDataIsValid_IsSuccessful()
        {
            // Arrange
            var meetingId = await CreateMeetingAsync(MeetingsModule, ExecutionContext);

            var meetingCommentId =
                await MeetingsModule.ExecuteCommandAsync(new AddMeetingCommentCommand(
                                                             meetingId,
                                                             "The meeting was great."));

            var editedComment = "It was very interesting!";

            var meetingCommentsBefore = await MeetingsModule.ExecuteQueryAsync(new GetMeetingCommentsQuery(meetingId));

            var originalMeetingComment = meetingCommentsBefore.Single();

            var date = new DateTime(2020, 1, 1, 01, 00, 00);

            SystemClock.Set(date);

            // Act
            await MeetingsModule.ExecuteCommandAsync(new EditMeetingCommentCommand(meetingCommentId, editedComment));

            // Assert
            var meetingCommentsAfter = await MeetingsModule.ExecuteQueryAsync(new GetMeetingCommentsQuery(meetingId));

            Assert.That(meetingCommentsAfter.Count, Is.EqualTo(1));
            var editedMeetingComment = meetingCommentsAfter.Single();

            Assert.That(editedMeetingComment.Comment, Is.EqualTo(editedComment));
            Assert.That(editedMeetingComment.EditDate, Is.EqualTo(date));
            Assert.That(editedMeetingComment.AuthorId, Is.EqualTo(originalMeetingComment.AuthorId));
            Assert.That(editedMeetingComment.CreateDate, Is.EqualTo(originalMeetingComment.CreateDate));
        }
        public async Task AddMeetingComment_WhenDataIsValid_IsSuccessful()
        {
            // Arrange
            var meetingId = await CreateMeetingAsync(MeetingsModule, ExecutionContext);

            var date = new DateTime(2020, 1, 1, 01, 00, 00);

            SystemClock.Set(date);
            var comment = "The meeting was great.";

            // Act
            var meetingCommentId = await MeetingsModule.ExecuteCommandAsync(new AddMeetingCommentCommand(meetingId, comment));

            // Assert
            var meetingComments = await MeetingsModule.ExecuteQueryAsync(new GetMeetingCommentsQuery(meetingId));

            Assert.That(meetingComments.Count, Is.EqualTo(1));
            var meetingComment = meetingComments.Single();

            Assert.That(meetingComment.Id, Is.EqualTo(meetingCommentId));
            Assert.That(meetingComment.Comment, Is.EqualTo(comment));
            Assert.That(meetingComment.AuthorId, Is.EqualTo(ExecutionContext.UserId));
            Assert.That(meetingComment.CreateDate, Is.EqualTo(date));
            Assert.That(meetingComment.EditDate, Is.Null);
        }
Example #7
0
        public async Task CreateMeeting_Test()
        {
            // Arrange
            await MeetingsModule.ExecuteCommandAsync(new CreateMemberCommand(
                                                         Guid.NewGuid(),
                                                         ExecutionContext.UserId,
                                                         "johndoe",
                                                         "*****@*****.**",
                                                         "John",
                                                         "Doe",
                                                         "John Doe"));

            // Act
            var meetingId = await MeetingHelper.CreateMeetingAsync(
                MeetingsModule,
                ExecutionContext);

            // Assert
            var meetingDetails = await MeetingsModule.ExecuteQueryAsync(new GetMeetingDetailsQuery(meetingId));

            Assert.That(meetingDetails, Is.Not.Null);

            var meetingAttendees =
                await MeetingsModule.ExecuteQueryAsync(new GetMeetingAttendeesQuery(meetingId));

            Assert.That(meetingAttendees.Count, Is.EqualTo(1));
        }
Example #8
0
        public async Task BeforeEachTest()
        {
            const string connectionStringEnvironmentVariable =
                "ASPNETCORE_MyMeetings_IntegrationTests_ConnectionString";

            ConnectionString = EnvironmentVariablesProvider.GetVariable(connectionStringEnvironmentVariable);
            if (ConnectionString == null)
            {
                throw new ApplicationException(
                          $"Define connection string to integration tests database using environment variable: {connectionStringEnvironmentVariable}");
            }

            using (var sqlConnection = new SqlConnection(ConnectionString))
            {
                await ClearDatabase(sqlConnection);
            }

            Logger           = Substitute.For <ILogger>();
            EmailSender      = Substitute.For <IEmailSender>();
            ExecutionContext = new ExecutionContextMock(Guid.NewGuid());

            MeetingsStartup.Initialize(
                ConnectionString,
                ExecutionContext,
                Logger,
                new EmailsConfiguration("*****@*****.**"),
                null);

            MeetingsModule = new MeetingsModule();
        }
 public void EnableMeetingCommenting_WhenConfigurationNotExist_ThrowsInvalidCommandException()
 {
     // Assert
     Assert.CatchAsync <InvalidCommandException>(async() =>
     {
         // Act
         await MeetingsModule.ExecuteCommandAsync(new EnableMeetingCommentingConfigurationCommand(Guid.NewGuid()));
     });
 }
 public void UnlikeMeetingComment_WhenCommentNotExists_ThrowsInvalidCommandException()
 {
     // Assert
     Assert.CatchAsync <InvalidCommandException>(async() =>
     {
         // Act
         await MeetingsModule.ExecuteCommandAsync(new RemoveMeetingCommentLikeCommand(meetingCommentId: Guid.NewGuid()));
     });
 }
Example #11
0
        public async Task CreateMeetingCommentingCofiguration_WhenDataIsValid_IsSuccessful()
        {
            // Act
            var meetingId = await MeetingHelper.CreateMeetingAsync(MeetingsModule, ExecutionContext);

            // Assert
            var meetingCommentingConfiguration = await MeetingsModule.ExecuteQueryAsync(new GetMeetingCommentingConfigurationQuery(meetingId));

            Assert.NotNull(meetingCommentingConfiguration);
        }
Example #12
0
 public void ProposeMeetingGroup_WhenNoLocationProvided_ThrowsInvalidCommandException()
 {
     Assert.CatchAsync <InvalidCommandException>(async() =>
     {
         await MeetingsModule.ExecuteCommandAsync(new ProposeMeetingGroupCommand(
                                                      MeetingGroupProposalSampleData.Name,
                                                      MeetingGroupProposalSampleData.Description,
                                                      null,
                                                      null));
     });
 }
 public void EditMeetingComment_WhenItIsNonexistent_ThrowsInvalidCommandException()
 {
     // Assert
     Assert.CatchAsync <InvalidCommandException>(async() =>
     {
         // Act
         await MeetingsModule.ExecuteCommandAsync(new EditMeetingCommentCommand(
                                                      meetingCommentId: Guid.NewGuid(),
                                                      "Edit a nonexistent comment."));
     });
 }
 public void AddMeetingComment_WhenMeetingIsNonexistent_ThrowsInvalidCommandException()
 {
     // Assert
     Assert.CatchAsync <InvalidCommandException>(async() =>
     {
         // Act
         await MeetingsModule.ExecuteCommandAsync(new AddMeetingCommentCommand(
                                                      meetingId: Guid.NewGuid(),
                                                      "Comment for a nonexistent meeting."));
     });
 }
Example #15
0
 public void RemoveMeetingComment_WhenItIsNonexistent_ThrowsInvalidCommandException()
 {
     // Assert
     Assert.CatchAsync <InvalidCommandException>(async() =>
     {
         // Act
         await MeetingsModule.ExecuteCommandAsync(new RemoveMeetingCommentCommand(
                                                      meetingCommentId: Guid.NewGuid(),
                                                      reason: String.Empty));
     });
 }
Example #16
0
 public void AddReply_WhenParentCommentNotExists_ThrowsInvalidCommandException()
 {
     // Assert
     Assert.CatchAsync <InvalidCommandException>(async() =>
     {
         // Act
         await MeetingsModule.ExecuteCommandAsync(new AddReplyToMeetingCommentCommand(
                                                      inReplyToCommentId: Guid.NewGuid(),
                                                      "Reply for a nonexistent comment."));
     });
 }
        public async Task GetCountriesTest()
        {
            // Arrange
            await ExecuteScript("Countries/0001_SeedCountries.sql");

            // Act
            var countries = await MeetingsModule.ExecuteQueryAsync(new GetAllCountriesQuery());

            // Assert
            Assert.That(countries, Is.Not.Empty);
            Assert.That(countries.Any(x => x.Code == "PL"));
        }
Example #18
0
        public async Task DisableMeetingCommenting_WhenDataIsValid_IsSuccess()
        {
            // Arrange
            var meetingId = await MeetingHelper.CreateMeetingAsync(MeetingsModule, ExecutionContext);

            // Act
            await MeetingsModule.ExecuteCommandAsync(new DisableMeetingCommentingConfigurationCommand(meetingId));

            // Assert
            var meetingConfiguration = await MeetingsModule.ExecuteQueryAsync(new GetMeetingCommentingConfigurationQuery(meetingId));

            Assert.NotNull(meetingConfiguration);
            Assert.False(meetingConfiguration.IsCommentingEnabled);
        }
Example #19
0
        public async Task RemoveMeetingComment_ByAuthor_WhenDataIsValid_IsSuccessful()
        {
            //Arrange
            var meetingId = await CreateMeetingAsync(MeetingsModule, ExecutionContext);

            var meetingCommentId = await MeetingsModule.ExecuteCommandAsync(new AddMeetingCommentCommand(meetingId, "The meeting was great."));

            // Act
            await MeetingsModule.ExecuteCommandAsync(new RemoveMeetingCommentCommand(meetingCommentId, reason : string.Empty));

            //Assert
            var meetingComments = await MeetingsModule.ExecuteQueryAsync(new GetMeetingCommentsQuery(meetingId));

            Assert.IsEmpty(meetingComments);
        }
Example #20
0
        public async Task GetMeetingGroupProposals_Test()
        {
            await MeetingsModule.ExecuteCommandAsync(new ProposeMeetingGroupCommand(
                                                         "Name 1",
                                                         "Desc 1",
                                                         "Warsaw",
                                                         "PL"
                                                         ));

            await MeetingsModule.ExecuteCommandAsync(new ProposeMeetingGroupCommand(
                                                         "Name 2",
                                                         "Desc 2",
                                                         "London",
                                                         "GB"
                                                         ));

            await MeetingsModule.ExecuteCommandAsync(new ProposeMeetingGroupCommand(
                                                         "Name 3",
                                                         "Desc 3",
                                                         "Rome",
                                                         "IT"
                                                         ));

            await MeetingsModule.ExecuteCommandAsync(new ProposeMeetingGroupCommand(
                                                         "Name 4",
                                                         "Desc 4",
                                                         "Madrid",
                                                         "ES"
                                                         ));

            await MeetingsModule.ExecuteCommandAsync(new ProposeMeetingGroupCommand(
                                                         "Name 5",
                                                         "Desc 5",
                                                         "Berlin",
                                                         "DE"
                                                         ));

            var allProposals = await MeetingsModule.ExecuteQueryAsync(new GetMeetingGroupProposalsQuery(null, null));

            Assert.That(allProposals.Count, Is.EqualTo(5));

            var proposalsPaged = await MeetingsModule.ExecuteQueryAsync(new GetMeetingGroupProposalsQuery(2, 2));

            Assert.That(proposalsPaged.Count, Is.EqualTo(2));
            Assert.That(proposalsPaged[0].Name, Is.EqualTo("Name 3"));
            Assert.That(proposalsPaged[1].Name, Is.EqualTo("Name 4"));
        }
Example #21
0
        public async Task CreateMeetingGroupScenario_WhenProposalIsAccepted()
        {
            var meetingGroupId = await MeetingsModule.ExecuteCommandAsync(
                new ProposeMeetingGroupCommand("Name",
                                               "Description",
                                               "Location",
                                               "PL"));

            AssertEventually(
                new GetMeetingGroupProposalFromAdministrationProbe(meetingGroupId, AdministrationModule),
                10000);

            await AdministrationModule.ExecuteCommandAsync(new AcceptMeetingGroupProposalCommand(meetingGroupId));

            AssertEventually(
                new GetCreatedMeetingGroupFromMeetingsProbe(meetingGroupId, MeetingsModule),
                15000);
        }
        public async Task GetMeetingComments_Test()
        {
            // Arrange
            var meetingId = await MeetingHelper.CreateMeetingAsync(MeetingsModule, ExecutionContext);

            await MeetingsModule.ExecuteCommandAsync(
                new AddMeetingCommentCommand(meetingId, "The meeting was great."));

            await MeetingsModule.ExecuteCommandAsync(
                new AddMeetingCommentCommand(meetingId, "The meeting was wonderful."));

            await MeetingsModule.ExecuteCommandAsync(
                new AddMeetingCommentCommand(meetingId, "The meeting was amazing."));

            // Act
            var meetingComments = await MeetingsModule.ExecuteQueryAsync(new GetMeetingCommentsQuery(meetingId));

            // Assert
            Assert.That(meetingComments.Count, Is.EqualTo(3));
        }
        public async Task ProposeAndAcceptMeetingGroup_WhenDataIsValid_IsSuccessful()
        {
            var proposalId = await MeetingsModule.ExecuteCommandAsync(new ProposeMeetingGroupCommand(
                                                                          MeetingGroupProposalSampleData.Name,
                                                                          MeetingGroupProposalSampleData.Description,
                                                                          MeetingGroupProposalSampleData.LocationCity,
                                                                          MeetingGroupProposalSampleData.LocationCountryCode
                                                                          ));

            await MeetingsModule.ExecuteCommandAsync(new AcceptMeetingGroupProposalCommand(Guid.NewGuid(), proposalId));

            var meetingGroupProposal = await MeetingsModule.ExecuteQueryAsync(new GetMeetingGroupProposalQuery(proposalId));

            Assert.That(meetingGroupProposal.Id, Is.EqualTo(proposalId));
            Assert.That(meetingGroupProposal.Name, Is.EqualTo(MeetingGroupProposalSampleData.Name));
            Assert.That(meetingGroupProposal.Description, Is.EqualTo(MeetingGroupProposalSampleData.Description));
            Assert.That(meetingGroupProposal.LocationCity, Is.EqualTo(MeetingGroupProposalSampleData.LocationCity));
            Assert.That(meetingGroupProposal.LocationCountryCode, Is.EqualTo(MeetingGroupProposalSampleData.LocationCountryCode));
            Assert.That(meetingGroupProposal.StatusCode, Is.EqualTo("Accepted"));
        }