コード例 #1
0
        public async Task Entity_InMemory_BreakForeignKey()
        {
            var options = new DbContextOptionsBuilder <SportsDbContext>()
                          .UseInMemoryDatabase(databaseName: "test1")
                          .Options;

            using (var context = new SportsDbContext(options))
            {
                context.Leagues.Add(LeagueFactory.NewLeague(1));
                context.Leagues.Add(LeagueFactory.NewLeague(2));
                context.SaveChanges();
            }

            using (var context = new SportsDbContext(options))
            {
                var result = await context.Leagues
                             .Include(x => x.Conferences)
                             .Include(x => x.Divisions)
                             .Include(x => x.Teams)
                             .Include(x => x.Seasons).ThenInclude(x => x.TeamMaps).ToListAsync();

                //should be able to get the team maps with the navigation properties
                Console.WriteLine(result[0].Seasons[0].TeamMaps[0]);
            }
        }
        protected override CreateLeagueCommand CreateCommand()
        {
            var regionmodel = Region.Create("region", "www.test.com");
            var model       = LeagueFactory.GetModel(20, "LSTN", "LeagueFullTestName", "https://www.flagTest.png", regionmodel);

            return(new CreateLeagueCommand(model));
        }
コード例 #3
0
ファイル: LeagueService.cs プロジェクト: Brendon-Coombes/dihl
 public LeagueService(IActionHandler handler, ILeagueRepository leagueRepository, LeagueDTOMapper leagueMapper, LeagueFactory leagueFactory, ITelemetryEventService telemetry)
     : base(handler)
 {
     _leagueRepository = leagueRepository;
     _leagueMapper     = leagueMapper;
     _leagueFactory    = leagueFactory;
     _telemetry        = telemetry;
 }
コード例 #4
0
 public FakeFantasyCriticRepo(FakeFantasyCriticUserStore userStore, FakeMasterGameRepo fakeMasterGameRepo)
 {
     _userStore          = userStore;
     _fakeMasterGameRepo = fakeMasterGameRepo;
     _leagues            = LeagueFactory.GetLeagues();
     _leagueYears        = LeagueFactory.GetLeagueYears();
     _usersInLeagues     = LeagueFactory.GetUsersInLeagues();
     _publishers         = PublisherFactory.GetPublishers();
     _publisherGames     = PublisherFactory.GetPublisherGames();
 }
コード例 #5
0
        public static IEnumerable <TestCaseData> AddSeason_TestCases()
        {
            string s       = "{m}_";
            var    league1 = LeagueFactory.NBA(1);
            var    other1  = LeagueFactory.NHL(2);

            yield return(new TestCaseData(league1, Season.New(league1, 1, NewRange(1))).SetName(s + "Valid").Returns(true));

            yield return(new TestCaseData(league1, Season.New(other1, 2, NewRange(4))).SetName(s + "WrongLeague").Returns(false));

            yield return(new TestCaseData(league1, Season.New(league1, 3, NewRange(1))).SetName(s + "OverlapRange").Returns(false));
        }
コード例 #6
0
        public static IEnumerable <TestCaseData> AddTeam_TestCases()
        {
            string s       = "{m}_";
            var    league1 = LeagueFactory.NBA(1);
            var    other1  = LeagueFactory.NHL(2);

            yield return(new TestCaseData(league1, Team.New(league1, 1, "a", "b")).SetName(s + "Valid").Returns(true));

            yield return(new TestCaseData(league1, Team.New(league1, 2, "a", "b1")).SetName(s + "NameNotUnique").Returns(false));

            yield return(new TestCaseData(league1, Team.New(league1, 3, "a1", "b")).SetName(s + "AbbrNotUnique").Returns(false));

            yield return(new TestCaseData(league1, Team.New(other1, 4, "a2", "b2")).SetName(s + "WrongLeague").Returns(false));
        }
コード例 #7
0
        public void Given_Retrieve_When_PassedValidQuery_Then_Should_ReturnAllLeagues()
        {
            var region  = Region.Create("regiontest", "www.test.ro");
            var leagues = LeagueFactory.GetEntity(20, "LSTN", "LeagueFullTestName",
                                                  "https://www.flagTest.png", region).ToQueryableCollection();

            RepositoryMock.Setup(r => r.GetAll()).Returns(leagues);
            var models = LeagueFactory.GetModel(leagues.First()).ToReadOnlyCollection();

            MapperMock.Setup(m => m.Map <IReadOnlyCollection <LeagueModel> >(leagues)).Returns(models);

            var result = ExecuteQuery();

            result.Should().NotBeNull();
            result.Leagues.Should().NotBeNull();
        }
コード例 #8
0
        public async Task Entity_SqlLite_ForeignKey()
        {
            var options = new DbContextOptionsBuilder <SportsDbContext>()
                          .UseInMemoryDatabase(databaseName: "test2")
                          .Options;

            using (var context = new SportsDbContext(options))
            {
                context.Leagues.Add(LeagueFactory.NewLeague(1));
                context.SaveChanges();
            }

            //change the team
            using (var context = new SportsDbContext(options))
            {
                var league = await context.Leagues.Include(x => x.Teams).FirstAsync();

                context.Update(league);
                league.Teams.First().Name = "abc";
                league.Teams.Add(new TeamDao()
                {
                    Name = "zz"
                });
                context.SaveChanges();
                var league2 = await context.Leagues.Include(x => x.Teams).FirstAsync();

                //league.Teams.Firs
                //var result = await context.Leagues
                //    .Include(x => x.Conferences)
                //    .Include(x => x.Divisions)
                //    .Include(x => x.Teams)
                //    .Include(x => x.Seasons).ThenInclude(x => x.TeamMaps).ToListAsync();
                //should be able to get the team maps with the navigation properties
                Console.WriteLine("done");
            }
        }