Ejemplo n.º 1
0
 /// <summary>
 /// 種目の一覧を作成します。
 /// </summary>
 /// <returns>種目の一覧。</returns>
 public List <SelectListItem> CreateTennisEvents()
 {
     return(TennisEvent
            .GetAllEvents()
            .Select(o => new SelectListItem(o.Value.DisplayTournamentEvent, o.Key, this.IsSelected(this.SelectedTennisEvents, o.Key)))
            .ToList());
 }
Ejemplo n.º 2
0
        public static void Create(JuniorTennisDbContext context)
        {
            try
            {
                if (context.Tournaments.Any())
                {
                    return;
                }

                for (var i = 0; i < 10; i++)
                {
                    var tournament = new Tournament(
                        new TournamentName($"大阪府代表選考会 {i:000}"),
                        TournamentType.WithDraw,
                        new RegistrationYear(new DateTime(2020, 4, 1)),
                        TypeOfYear.Odd,
                        new AggregationMonth(new DateTime(2020, 8, 1)),
                        TennisEvent.GetAllEvents().Select(o => o.Value).ToList(),
                        new HoldingPeriod(new DateTime(2020, 8, 1), new DateTime(2020, 8, 31)),
                        Enumerable.Range(1, 31)
                        .Select(o => new HoldingDate(new DateTime(2020, 8, o)))
                        .Where(o => o.Value.DayOfWeek == DayOfWeek.Saturday || o.Value.DayOfWeek == DayOfWeek.Sunday)
                        .ToList(),
                        new Venue($"大阪スタジアム {i:000}"),
                        new EntryFee(1000 + i),
                        MethodOfPayment.PrePayment,
                        new ApplicationPeriod(new DateTime(2020, 7, 25), new DateTime(2020, 7, 31)),
                        new Outline($"大会要領 {i:000}"),
                        "",
                        ""
                        );

                    context.Tournaments.Add(tournament);
                }

                context.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Ejemplo n.º 3
0
        public void 全ての種目一覧を取得()
        {
            var act = TennisEvent.GetAllEvents();

            Assert.Equal(new TennisEvent(Category.Under17Or18, Gender.Boys, Format.Singles),
                         act.Values.First());
            Assert.Equal(new TennisEvent(Category.Under17Or18, Gender.Boys, Format.Doubles),
                         act.Values.Skip(1).First());
            Assert.Equal(new TennisEvent(Category.Under17Or18, Gender.Girls, Format.Singles),
                         act.Values.Skip(2).First());
            Assert.Equal(new TennisEvent(Category.Under17Or18, Gender.Girls, Format.Doubles),
                         act.Values.Skip(3).First());
            Assert.Equal(new TennisEvent(Category.Under15Or16, Gender.Boys, Format.Singles),
                         act.Values.Skip(4).First());
            Assert.Equal(new TennisEvent(Category.Under15Or16, Gender.Boys, Format.Doubles),
                         act.Values.Skip(5).First());
            Assert.Equal(new TennisEvent(Category.Under15Or16, Gender.Girls, Format.Singles),
                         act.Values.Skip(6).First());
            Assert.Equal(new TennisEvent(Category.Under15Or16, Gender.Girls, Format.Doubles),
                         act.Values.Skip(7).First());
            Assert.Equal(new TennisEvent(Category.Under13Or14, Gender.Boys, Format.Singles),
                         act.Values.Skip(8).First());
            Assert.Equal(new TennisEvent(Category.Under13Or14, Gender.Boys, Format.Doubles),
                         act.Values.Skip(9).First());
            Assert.Equal(new TennisEvent(Category.Under13Or14, Gender.Girls, Format.Singles),
                         act.Values.Skip(10).First());
            Assert.Equal(new TennisEvent(Category.Under13Or14, Gender.Girls, Format.Doubles),
                         act.Values.Skip(11).First());
            Assert.Equal(new TennisEvent(Category.Under11Or12, Gender.Boys, Format.Singles),
                         act.Values.Skip(12).First());
            Assert.Equal(new TennisEvent(Category.Under11Or12, Gender.Boys, Format.Doubles),
                         act.Values.Skip(13).First());
            Assert.Equal(new TennisEvent(Category.Under11Or12, Gender.Girls, Format.Singles),
                         act.Values.Skip(14).First());
            Assert.Equal(new TennisEvent(Category.Under11Or12, Gender.Girls, Format.Doubles),
                         act.Values.Skip(15).First());
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 種目の一覧を作成します。
 /// </summary>
 /// <returns>種目の一覧。</returns>
 private List <SelectListItem> CreateTennisEvents() =>
 TennisEvent
 .GetAllEvents()
 .Select(o => new SelectListItem(o.Value.DisplayTournamentEvent, o.Key))
 .ToList();
Ejemplo n.º 5
0
        public async void 大会一覧が開催開始日の降順かつIDの昇順で取得されること()
        {
            var initialData = new List <Tournament>()
            {
                new Tournament(
                    tournamentName: new TournamentName("大会名 001"),
                    tournamentType: TournamentType.WithDraw,
                    registrationYear: new RegistrationYear(new DateTime(2020, 4, 1)),
                    typeOfYear: TypeOfYear.Odd,
                    aggregationMonth: new AggregationMonth(new DateTime(2020, 8, 1)),
                    tennisEvents: TennisEvent.GetAllEvents().Select(o => (o.Value)).ToList(),
                    holdingPeriod: new HoldingPeriod(new DateTime(2020, 8, 2), new DateTime(2020, 8, 31)),
                    holdingDates: new List <HoldingDate>()
                {
                    new HoldingDate(new DateTime(2020, 8, 2))
                },
                    venue: new Venue($"会場名"),
                    entryFee: new EntryFee(1000),
                    methodOfPayment: MethodOfPayment.PrePayment,
                    applicationPeriod: new ApplicationPeriod(new DateTime(2020, 7, 25), new DateTime(2020, 7, 31)),
                    outline: new Outline($"大会要領"),
                    tournamentEntryReceptionMailSubject: "メール件名",
                    tournamentEntryReceptionMailBody: "メール本文"
                    ),
                new Tournament(
                    tournamentName: new TournamentName("大会名 004"),
                    tournamentType: TournamentType.WithDraw,
                    registrationYear: new RegistrationYear(new DateTime(2020, 4, 1)),
                    typeOfYear: TypeOfYear.Odd,
                    aggregationMonth: new AggregationMonth(new DateTime(2020, 8, 1)),
                    tennisEvents: TennisEvent.GetAllEvents().Select(o => (o.Value)).ToList(),
                    holdingPeriod: new HoldingPeriod(new DateTime(2020, 8, 3), new DateTime(2020, 8, 31)),
                    holdingDates: new List <HoldingDate>()
                {
                    new HoldingDate(new DateTime(2020, 8, 3))
                },
                    venue: new Venue($"会場名"),
                    entryFee: new EntryFee(1000),
                    methodOfPayment: MethodOfPayment.PrePayment,
                    applicationPeriod: new ApplicationPeriod(new DateTime(2020, 7, 25), new DateTime(2020, 7, 31)),
                    outline: new Outline($"大会要領"),
                    tournamentEntryReceptionMailSubject: "メール件名",
                    tournamentEntryReceptionMailBody: "メール本文"
                    ),
                new Tournament(
                    tournamentName: new TournamentName("大会名 003"),
                    tournamentType: TournamentType.WithDraw,
                    registrationYear: new RegistrationYear(new DateTime(2020, 4, 1)),
                    typeOfYear: TypeOfYear.Odd,
                    aggregationMonth: new AggregationMonth(new DateTime(2020, 8, 1)),
                    tennisEvents: TennisEvent.GetAllEvents().Select(o => (o.Value)).ToList(),
                    holdingPeriod: new HoldingPeriod(new DateTime(2020, 8, 1), new DateTime(2020, 8, 31)),
                    holdingDates: new List <HoldingDate>()
                {
                    new HoldingDate(new DateTime(2020, 8, 1))
                },
                    venue: new Venue($"会場名"),
                    entryFee: new EntryFee(1000),
                    methodOfPayment: MethodOfPayment.PrePayment,
                    applicationPeriod: new ApplicationPeriod(new DateTime(2020, 7, 25), new DateTime(2020, 7, 31)),
                    outline: new Outline($"大会要領"),
                    tournamentEntryReceptionMailSubject: "メール件名",
                    tournamentEntryReceptionMailBody: "メール本文"
                    ),
                new Tournament(
                    tournamentName: new TournamentName("大会名 002"),
                    tournamentType: TournamentType.WithDraw,
                    registrationYear: new RegistrationYear(new DateTime(2020, 4, 1)),
                    typeOfYear: TypeOfYear.Odd,
                    aggregationMonth: new AggregationMonth(new DateTime(2020, 8, 1)),
                    tennisEvents: TennisEvent.GetAllEvents().Select(o => (o.Value)).ToList(),
                    holdingPeriod: new HoldingPeriod(new DateTime(2020, 8, 3), new DateTime(2020, 8, 31)),
                    holdingDates: new List <HoldingDate>()
                {
                    new HoldingDate(new DateTime(2020, 8, 3))
                },
                    venue: new Venue($"会場名"),
                    entryFee: new EntryFee(1000),
                    methodOfPayment: MethodOfPayment.PrePayment,
                    applicationPeriod: new ApplicationPeriod(new DateTime(2020, 7, 25), new DateTime(2020, 7, 31)),
                    outline: new Outline($"大会要領"),
                    tournamentEntryReceptionMailSubject: "メール件名",
                    tournamentEntryReceptionMailBody: "メール本文"
                    ),
            };

            initialData[0].Id = 1;
            initialData[1].Id = 4;
            initialData[2].Id = 3;
            initialData[3].Id = 2;

            var mockRepository = new Mock <ITournamentRepository>();

            mockRepository.Setup(o => o.Find())
            .ReturnsAsync(initialData)
            .Verifiable();

            var tournamentUseCase    = new TournamentUseCase(mockRepository.Object);
            var mockDrawTableUseCase = new Mock <IDrawTableUseCase>();

            var controller = new DrawTablesController(tournamentUseCase, mockDrawTableUseCase.Object);
            var jsonString = await controller.GetTournaments();

            var json = JsonSerializer
                       .Deserialize <JsonElement>(jsonString)
                       .EnumerateArray()
                       .ToList();

            mockRepository.Verify();
            Assert.Equal("大会名 002", JsonConverter.ToString(json[0].GetProperty("name")));
            Assert.Equal("大会名 004", JsonConverter.ToString(json[1].GetProperty("name")));
            Assert.Equal("大会名 001", JsonConverter.ToString(json[2].GetProperty("name")));
            Assert.Equal("大会名 003", JsonConverter.ToString(json[3].GetProperty("name")));
        }