예제 #1
0
        public async Task ReportingManager_GetNumberOfMembersReport_ReportDataReturned()
        {
            String databaseName            = Guid.NewGuid().ToString("N");
            ManagementAPIReadModel context = this.GetContext(databaseName);

            List <GolfClubMembershipReporting> reportingData = new List <GolfClubMembershipReporting>();

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-20),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 1,
                PlayerGender     = "M",
                PlayerName       = "Test Player 1"
            });

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-25),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 2,
                PlayerGender     = "M",
                PlayerName       = "Test Player 2"
            });
            await context.GolfClubMembershipReporting.AddRangeAsync(reportingData, CancellationToken.None);

            await context.SaveChangesAsync(CancellationToken.None);

            Func <ManagementAPIReadModel> contextResolver = () => { return(context); };

            ReportingManager reportingManager = new ReportingManager(contextResolver);

            GetNumberOfMembersReportResponse reportData = await reportingManager.GetNumberOfMembersReport(GolfClubTestData.AggregateId, CancellationToken.None);

            reportData.GolfClubId.ShouldBe(GolfClubTestData.AggregateId);
            reportData.NumberOfMembers.ShouldBe(reportingData.Count);
        }
예제 #2
0
        public async Task ReportingManager_GetMembersHandicapListReport_ReportDataReturned()
        {
            String databaseName            = Guid.NewGuid().ToString("N");
            ManagementAPIReadModel context = this.GetContext(databaseName);

            List <PlayerHandicapListReporting> reportingData = new List <PlayerHandicapListReporting>();

            reportingData.Add(new PlayerHandicapListReporting
            {
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                HandicapCategory = 1,
                PlayerName       = "Test Player 1",
                ExactHandicap    = 5.4m,
                PlayingHandicap  = 5
            });

            reportingData.Add(new PlayerHandicapListReporting
            {
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                HandicapCategory = 2,
                PlayerName       = "Test Player 2",
                ExactHandicap    = 12.8m,
                PlayingHandicap  = 13
            });
            await context.PlayerHandicapListReporting.AddRangeAsync(reportingData, CancellationToken.None);

            await context.SaveChangesAsync(CancellationToken.None);

            Func <ManagementAPIReadModel> contextResolver = () => { return(context); };

            ReportingManager reportingManager = new ReportingManager(contextResolver);

            GetMembersHandicapListReportResponse reportData = await reportingManager.GetMembersHandicapListReport(GolfClubTestData.AggregateId, CancellationToken.None);

            reportData.GolfClubId.ShouldBe(GolfClubTestData.AggregateId);
            reportData.MembersHandicapListReportResponse.ShouldNotBeEmpty();
            reportData.MembersHandicapListReportResponse.Count.ShouldBe(reportingData.Count);
        }
예제 #3
0
        public async Task ReportingManager_GetPlayerScores_ReportDataReturned()
        {
            String databaseName            = Guid.NewGuid().ToString("N");
            ManagementAPIReadModel context = this.GetContext(databaseName);

            List <PublishedPlayerScore> reportingData = new List <PublishedPlayerScore>();

            reportingData.Add(new PublishedPlayerScore
            {
                TournamentDate   = TournamentTestData.TournamentDate,
                PlayerId         = PlayerTestData.AggregateId,
                TournamentFormat = TournamentTestData.TournamentFormat,
                GolfClubId       = TournamentTestData.GolfClubId,
                MeasuredCourseId = TournamentTestData.MeasuredCourseId,
                TournamentId     = TournamentTestData.AggregateId,
                CSS                     = TournamentTestData.CSS,
                NetScore                = TournamentTestData.NetScore,
                MeasuredCourseName      = GolfClubTestData.MeasuredCourseName,
                GolfClubName            = GolfClubTestData.Name,
                MeasuredCourseTeeColour = GolfClubTestData.TeeColour,
                GrossScore              = TournamentTestData.GrossScore,
                TournamentName          = TournamentTestData.Name
            });

            await context.PublishedPlayerScores.AddRangeAsync(reportingData, CancellationToken.None);

            await context.SaveChangesAsync(CancellationToken.None);

            Func <ManagementAPIReadModel> contextResolver = () => { return(context); };

            ReportingManager reportingManager = new ReportingManager(contextResolver);

            GetPlayerScoresResponse reportData = await reportingManager.GetPlayerScoresReport(PlayerTestData.AggregateId, 10, CancellationToken.None);

            reportData.Scores.Count.ShouldBe(reportingData.Count);
        }
예제 #4
0
        public async Task ReportingManager_GetNumberOfMembersByAgeCategoryReport_ReportDataReturned()
        {
            String databaseName            = Guid.NewGuid().ToString("N");
            ManagementAPIReadModel context = this.GetContext(databaseName);

            List <GolfClubMembershipReporting> reportingData = new List <GolfClubMembershipReporting>();

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-16),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 1,
                PlayerGender     = "M",
                PlayerName       = "Test Player 1"
            });

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-18),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 2,
                PlayerGender     = "M",
                PlayerName       = "Test Player 2"
            });

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-18),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 2,
                PlayerGender     = "M",
                PlayerName       = "Test Player 3"
            });

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-19),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 2,
                PlayerGender     = "M",
                PlayerName       = "Test Player 4"
            });

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-20),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 3,
                PlayerGender     = "M",
                PlayerName       = "Test Player 5"
            });

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-22),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 3,
                PlayerGender     = "M",
                PlayerName       = "Test Player 6"
            });

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-24),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 3,
                PlayerGender     = "M",
                PlayerName       = "Test Player 7"
            });

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-26),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 3,
                PlayerGender     = "M",
                PlayerName       = "Test Player 8"
            });

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-35),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 3,
                PlayerGender     = "M",
                PlayerName       = "Test Player 9"
            });

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-64),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 3,
                PlayerGender     = "M",
                PlayerName       = "Test Player 10"
            });

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-65),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 3,
                PlayerGender     = "M",
                PlayerName       = "Test Player 11"
            });

            reportingData.Add(new GolfClubMembershipReporting
            {
                DateJoined       = DateTime.Now,
                DateOfBirth      = DateTime.Now.AddYears(-70),
                PlayerId         = Guid.NewGuid(),
                GolfClubId       = GolfClubTestData.AggregateId,
                GolfClubName     = GolfClubTestData.Name,
                HandicapCategory = 3,
                PlayerGender     = "M",
                PlayerName       = "Test Player 12"
            });

            await context.GolfClubMembershipReporting.AddRangeAsync(reportingData, CancellationToken.None);

            await context.SaveChangesAsync(CancellationToken.None);

            Func <ManagementAPIReadModel> contextResolver = () => { return(context); };

            ReportingManager reportingManager = new ReportingManager(contextResolver);

            GetNumberOfMembersByAgeCategoryReportResponse reportData = await reportingManager.GetNumberOfMembersByAgeCategoryReport(GolfClubTestData.AggregateId, CancellationToken.None);

            reportData.GolfClubId.ShouldBe(GolfClubTestData.AggregateId);
            reportData.MembersByAgeCategoryResponse.ShouldNotBeEmpty();
            reportData.MembersByAgeCategoryResponse.Single(q => q.AgeCategory == "Junior").NumberOfMembers.ShouldBe(1);
            reportData.MembersByAgeCategoryResponse.Single(q => q.AgeCategory == "Juvenile").NumberOfMembers.ShouldBe(2);
            reportData.MembersByAgeCategoryResponse.Single(q => q.AgeCategory == "Youth").NumberOfMembers.ShouldBe(2);
            reportData.MembersByAgeCategoryResponse.Single(q => q.AgeCategory == "Young Adult").NumberOfMembers.ShouldBe(2);
            reportData.MembersByAgeCategoryResponse.Single(q => q.AgeCategory == "Adult").NumberOfMembers.ShouldBe(3);
            reportData.MembersByAgeCategoryResponse.Single(q => q.AgeCategory == "Senior").NumberOfMembers.ShouldBe(2);
        }