Exemplo n.º 1
0
        public void ResetDatabase()
        {
            ClearDatabase();

            TeamDataService tds = new TeamDataService();

            tds.InsertTeams();

            //past
            CsvService csvs = new CsvService();

            csvs.InsertMatches("13-14.csv");
            csvs.InsertScores("13-14.csv");
            csvs.InsertMatches("14-15.csv");
            csvs.InsertScores("14-15.csv");
            csvs.InsertMatches("15-16.csv");
            csvs.InsertScores("15-16.csv");
            csvs.InsertMatches("16-17.csv");
            csvs.InsertScores("16-17.csv");

            CsvDownloader csvd = new CsvDownloader();

            csvd.GetScoresCsv(DateTime.Now);

            ApiService aps = new ApiService();

            aps.InsertAllMatches();
            csvs.InsertScores("DebugCurrentScores.csv");
        }
Exemplo n.º 2
0
 public TeamListViewModel()
 {
     // Dependency traz uma implementação de SQLite trazendo a conexão.
     _dataService = new TeamDataService(DependencyService.Get <ISQLite>().GetConnection());
     //Entities é do tipo Observable Collection, que recebe uma lista. Aqui passamos a coleção de dados.
     Entities = new ObservableCollection <Team>(_dataService.Select());
 }
Exemplo n.º 3
0
        public async Task SelectAllTeams_Test_DAL_Method_Called()
        {
            var mockDAL    = new Mock <ITeamDAL>();
            var mockLogger = new Mock <ILogger <TeamDataService> >();

            // Setup Mock DAL
            IEnumerable <FootballTeam> teamsList = new List <FootballTeam>
            {
                new FootballTeam {
                    Id = 1234, Name = "Liverpool", Country = "England", Eliminated = false
                },
                new FootballTeam {
                    Id = 1234, Name = "Nottingham Forest", Country = "England", Eliminated = true
                },
                new FootballTeam {
                    Id = 1234, Name = "Derby County", Country = "England", Eliminated = false
                }
            };

            mockDAL.Setup(d => d.GetAllTeamsAsync()).Returns(Task.FromResult(teamsList));

            // Create Data Service
            var dataService = new TeamDataService(mockDAL.Object, mockLogger.Object);

            // Call Data Service
            var teams = await dataService.GetAllTeamsAsync();

            // Check DAL Get All Teams was Called Once
            mockDAL.Verify(d => d.GetAllTeamsAsync(), Times.Once);

            Assert.NotNull(teams);
            Assert.AreEqual(teams.Count, 3);
        }
Exemplo n.º 4
0
        public async Task UpdateTeam_Test_Verification()
        {
            var mockDAL    = new Mock <ITeamDAL>();
            var mockLogger = new Mock <ILogger <TeamDataService> >();

            var teamId = 1234;
            var team   = new FootballTeam {
                Id = teamId, Name = "Liverpool", Country = "England", Eliminated = false
            };

            var expectedResponse = new CommandResponse
            {
                RecordId = teamId,
                Action   = Services.Enums.CommandAction.Edit,
                Success  = true
            };

            // Setup DAL to return 1 Affected Row after Update
            mockDAL.Setup(d => d.UpdateTeamAsync(team)).Returns(Task.FromResult(1));

            // Create Data Service
            var dataService = new TeamDataService(mockDAL.Object, mockLogger.Object);

            // Call Update
            var response = await dataService.UpdateTeamAsync(team);

            // Check DAL Update Method was Called
            mockDAL.Verify(d => d.UpdateTeamAsync(team), Times.Once);

            Assert.AreEqual(expectedResponse.RecordId, response.RecordId);
            Assert.True(expectedResponse.Success);
        }
 public SelectMemberListViewModel(Team _currentTeam)
 {
     // Dependency traz uma implementação de SQLite trazendo a conexão.
     _dataService     = new UserDataService(DependencyService.Get <ISQLite>().GetConnection());
     _teamDataService = new TeamDataService(DependencyService.Get <ISQLite>().GetConnection());
     //Entities é do tipo Observable Collection, que recebe uma lista. Aqui passamos a coleção de dados.
     Entities          = new ObservableCollection <User>(_dataService.Select());
     this._currentTeam = _currentTeam;
 }
Exemplo n.º 6
0
        public async Task SelectSingleTeam_Test_DAL_Method_Called()
        {
            var mockDAL    = new Mock <ITeamDAL>();
            var mockLogger = new Mock <ILogger <TeamDataService> >();

            var teamId       = 1234;
            var expectedTeam = new FootballTeam {
                Id = teamId, Name = "Liverpool", Country = "England", Eliminated = false
            };

            mockDAL.Setup(d => d.GetTeamDetailsAsync(teamId)).Returns(Task.FromResult(expectedTeam));

            // Create Data Service
            var dataService = new TeamDataService(mockDAL.Object, mockLogger.Object);

            // Call Data Service
            var team = await dataService.GetFootballTeamAsync(teamId);

            // Check DAL Get Team Detail was Called Once
            mockDAL.Verify(d => d.GetTeamDetailsAsync(teamId), Times.Once);

            Assert.NotNull(team);
            Assert.AreEqual(team.Name, expectedTeam.Name);
        }
 public TeamRegisterViewModel()
 {
     _dataService = new TeamDataService(DependencyService.Get <ISQLite>().GetConnection());
     SetVisibility(CurrentTeam.TeamId == 0);
 }
 public TeamDetailsViewModel(Team CurrentTeam)
 {
     _teamDataService = new TeamDataService(DependencyService.Get <ISQLite>().GetConnection());
     _currentTeamUser = _teamDataService.ShowUserTeam(CurrentTeam);
 }