public void Initialize() { factory = new EncounterFactory(); sport = new Sport("Soccer", true); teamA = new Mock <Team>(1, "teamA", "photo", sport).Object; teamB = new Mock <Team>(2, "teamB", "photo", sport).Object; teamC = new Mock <Team>(3, "teamC", "photo", sport).Object; teamD = new Mock <Team>(4, "teamD", "photo", sport).Object; testFixture = new FixtureDto() { fixtureName = "ObligatorioDA2.BusinessLogic.FixtureAlgorithms.OneMatchFixture" , initialDate = DateTime.Today, daysBetweenRounds = 5, roundLength = 2 }; teamsCollection = GetTeamsList(); teamsNames = teamsCollection.Select(tn => tn.Name).ToList(); SetUpRepository(); mapper = new EncounterDtoMapper(teamStorage, matchStorage, sportStorage); context.Database.EnsureDeleted(); Mock <IAuthenticationService> auth = new Mock <IAuthenticationService>(); auth.Setup(a => a.GetConnectedUser()).Returns(GetFakeUser()); EncounterService service = new EncounterService(matchStorage, teamStorage, sportStorage, auth.Object); algorithmPaths = @".\"; Mock <ILoggerService> logService = new Mock <ILoggerService>(); fixtureService = new FixtureService(teamStorage, service, auth.Object, logService.Object); }
public async Task <ICollection <FixtureDto> > GetFixturesOnMatchdayAsync(int matchday) { var document = await this.context.OpenAsync(GlobalConstants.FixtureSource); var allFixtureDto = new List <FixtureDto>(); var idName = "jornada-" + matchday; var gameWeekFixture = document.QuerySelectorAll($"#{idName} tbody tr"); foreach (var item in gameWeekFixture) { var matchInfo = item.QuerySelectorAll($"td").Select(x => x.TextContent.Trim()).ToList(); var homeTeamName = this.FixClubName(matchInfo[0]); var awayTeamname = this.FixClubName(matchInfo[2]); var currMatch = new FixtureDto { Matchday = matchday, Result = matchInfo[1], HomeTeamId = this.clubRepo.All().FirstOrDefault(t => t.Name == homeTeamName).Id, AwayTeamId = this.clubRepo.All().FirstOrDefault(t => t.Name == awayTeamname).Id, Finished = item.QuerySelector(".col-resultado").GetAttribute("class").Contains("finalizado"), }; currMatch.Started = currMatch.Finished == true ? true : !item.QuerySelector(".col-resultado").GetAttribute("class").Contains("no-comenzado"); allFixtureDto.Add(currMatch); } return(allFixtureDto); }
public void SetUp() { dto = new FixtureDto() { Fullname = "the full name", Name = "Math", Namespace = "some namespace" }; selector = new FixtureSelector(dto); }
private void ValidateFixture(FixtureDto aFixture) { if (string.IsNullOrEmpty(aFixture.fixtureName)) { logger.Log(LogType.FIXTURE, LogMessage.FIXTURE_WRONG, GetConnectedUserName(), DateTime.Now); throw new ServiceException("Fixture name can't be empty", ErrorType.INVALID_DATA); } if (aFixture.initialDate.Equals(new DateTime())) { logger.Log(LogType.FIXTURE, LogMessage.FIXTURE_WRONG, GetConnectedUserName(), DateTime.Now); throw new ServiceException("Fixture date can't be empty", ErrorType.INVALID_DATA); } }
private IActionResult TryCreateFixture(string sportName, FixtureModelIn input) { IActionResult result; try { SetSession(); FixtureDto fixture = BuildDto(input); fixtureService.SetFixtureAlgorithm(fixture, fixtureConfig.Value.DllPath); result = TryCreate(input, sportName); } catch (ServiceException e) { result = errors.GenerateError(e); } return(result); }
private FixtureGenerator BuildFixtureAlgorithm(FixtureDto dto, string algorithmsPath) { int roundLength = dto.roundLength == 0 ? 1 : dto.roundLength; int daysBetweenRounds = dto.daysBetweenRounds == 0 ? 7 : dto.daysBetweenRounds; try { Type algortihmType = GetAlgorithmType(algorithmsPath, dto.fixtureName); object fromDll = Activator.CreateInstance(algortihmType, new object[] { dto.initialDate, roundLength, daysBetweenRounds }); FixtureGenerator algorithm = fromDll as FixtureGenerator; return(algorithm); } catch (IOException e) { throw new ServiceException(e.Message, ErrorType.ENTITY_NOT_FOUND); } catch (MissingMemberException e) { throw new ServiceException(e.Message, ErrorType.INVALID_DATA); } }
public FixtureSelector(FixtureDto dto) { _dto = dto; Height = 25; this.Horizontal(); _checkbox = this.Add <CheckBox>(); _checkbox.Padding = new Thickness(0, 5, 0, 0); _checkbox.VerticalAlignment = VerticalAlignment.Center; this.Add <System.Windows.Controls.Label>(l => { l.Content = dto.Name; l.VerticalAlignment = VerticalAlignment.Top; }); ToolTip = new ToolTip() { Content = dto.Fullname }; }
public void SetFixtureAlgorithm(FixtureDto aFixture, string algorithmsPath) { ValidateFixture(aFixture); FixtureAlgorithm = BuildFixtureAlgorithm(aFixture, algorithmsPath); }