public void TestRaceStatusChangedEventInvocation()
        {
            // Setup
            var raceDaoMock = new Mock <IRaceDao>();

            raceDaoMock.Setup(d => d.FindById(It.IsAny <int>()))
            .Returns(Task.FromResult(
                         new Race {
                Status = RaceStatus.Ready
            })
                     );

            var daoProvider = DaoProviderHelper.GetPartialDaoProvider(raceDao: raceDaoMock.Object);
            var raceService = new RaceService(daoProvider);

            var eventTriggered = false;

            raceService.RaceStatusChanged += (race, status) => eventTriggered = true;

            // Execute and Assert
            raceService.EditRace(new Race {
                Status = RaceStatus.Ready
            });
            Assert.False(eventTriggered);

            raceService.EditRace(new Race {
                Status = RaceStatus.InProgress
            });
            Assert.True(eventTriggered);
        }
        private async Task RefreshRaces()
        {
            var raceService = new RaceService();
            var allRaces    = await raceService.GetAll();

            while (_sampleDataSource.Races.Count() > 0)
            {
                _sampleDataSource.Races.RemoveAt(0);
            }

            foreach (var race in allRaces)
            {
                var sampleDataItem = new Race(
                    race.Id,
                    race.Date,
                    race.Sequence,
                    race.Type,
                    race.Location,
                    race.Comment,
                    race.RaceResultSet
                    );

                _sampleDataSource.Races.Add(sampleDataItem);
            }
        }
        public static async Task <string> UpdateRace(Race race)
        {
            var raceService = new RaceService();
            var response    = await raceService.UpdateRace(race);

            return(response.ToString());
        }
示例#4
0
 public CadastroAnimal()
 {
     InitializeComponent();
     ConfigurarCombobox();
     animalService = new AnimalService();
     raceService   = new RaceService();
 }
示例#5
0
        public void TrackTraits_SetTo_DriverResult()
        {
            // Arrange
            DriverResult driverResult = new DriverResult();
            TrackTrait   trackTrait1  = new TrackTrait {
                Trait = new Trait {
                    QualyPace = 1
                }
            };
            TrackTrait trackTrait2 = new TrackTrait {
                Trait = new Trait {
                    QualyPace = 2
                }
            };
            List <TrackTrait> trackTraits = new List <TrackTrait> {
                trackTrait1, trackTrait2
            };
            Weather weather = Weather.Sunny;

            // Act
            RaceService.SetTrackTraitMods(driverResult, trackTraits, weather);
            // Assert
            int expected = 3; // QualyMod should add up all QualyPace which results in an expected of 3

            Assert.Equal(expected, driverResult.QualyMod);
        }
示例#6
0
 public RaceController(RaceService raceService, GroupService groupService, ParticipantService participantService, TimingValueService timingValueService)
 {
     _raceService        = raceService;
     _groupService       = groupService;
     _participantService = participantService;
     _timingValueService = timingValueService;
 }
        public static async Task <string> DeleteRace(int id)
        {
            var raceService = new RaceService();
            var response    = await raceService.DeleteRace(id);

            return(response.ToString());
        }
        public void Service_is_created()
        {
            var mockLogger      = new Mock <ILogger>();
            var mockHistoryRepo = new Mock <IHistoryRepository>();
            var sut             = new RaceService(mockLogger.Object, mockHistoryRepo.Object);

            Assert.IsInstanceOf <RaceService>(sut);
        }
示例#9
0
        // GET: Race
        public ActionResult Index()
        {
            var         userId  = Guid.Parse(User.Identity.GetUserId());
            RaceService service = new RaceService(userId);
            var         race    = service.GetAllMyRaces();

            return(View(race));
        }
示例#10
0
        // GET: Race
        public IHttpActionResult Index()
        {
            var userId = Guid.Parse(User.Identity.GetUserId());
            //return new RaceService(userId);
            RaceService service = new RaceService(userId);

            return(Ok(service.GetAllMyRaces()));
        }
示例#11
0
        public void RaceService_GetRaceResult_should_return_raceResult_when_racefield_is_supported()
        {
            var raceDataConnectorService = new RaceDataConnectorService();

            var sut        = new RaceService(raceDataConnectorService);
            var raceResult = sut.GetRaceResult(RaceField.Caulfield);

            Assert.NotEmpty(raceResult.RaceHorseResults);
        }
 public AdvertisementController()
 {
     _appUserService       = new AppUserService();
     _cityService          = new CityService();
     _districtService      = new DistrictService();
     _pettypeService       = new PettypeService();
     _raceService          = new RaceService();
     _advertisementService = new AdvertisementService();
 }
示例#13
0
 public HomeController(
     HorseService horseService,
     RaceService raceService,
     JokeyService jokeyService)
 {
     _horseService = horseService;
     _raceService  = raceService;
     _jokeyService = jokeyService;
 }
示例#14
0
        public void TestTest()
        {
            RaceService   service   = new RaceService(Guid.Parse("00000000-0000-0000-0000-000000000000"));
            DnDRaceCreate something = new DnDRaceCreate();

            something.WeaponProficiencies = new List <string> {
                "AHHH"
            };
            //service.GetAllMyRaces();
            service.CreateRace(something);
        }
示例#15
0
 public Console(IConfiguration configuration, SaveLoad repo, TimingValueService timingValueService, RaceService raceService, ParticipantService participantService, GroupService groupService, CategoryService categoryService, ClassService classService)
 {
     _configuration      = configuration;
     _repo               = repo;
     _timingValueService = timingValueService;
     _raceService        = raceService;
     _participantService = participantService;
     _groupService       = groupService;
     _categoryService    = categoryService;
     _classService       = classService;
 }
示例#16
0
 private static void PopulateCache(string raceId)
 {
     using (var db = new RaceAnalysisDbContext())
     {
         var raceService = new RaceService(db);
         var athletes    = raceService.GetAthletes(
             new BasicRaceCriteria
         {
             SelectedRaceIds     = new string[] { raceId },
             SelectedAgeGroupIds = AgeGroup.Expand(new int[] { 0 }),
             SelectedGenderIds   = Gender.Expand(new int[] { 0 })
         }
             );
     }
 }
示例#17
0
        public RaceServiceTests()
        {
            _context                 = InMemoryContextBuilder.GetContext();
            _mockSeriesService       = new Mock <ISeriesService>();
            _mockBackgroundTaskQueue = new Mock <IBackgroundTaskQueue>();
            _mockLogger              = new Mock <ILogger <IRaceService> >();
            _mockServiceScopeFactory = new Mock <IServiceScopeFactory>();
            _mapper  = MapperBuilder.GetSailScoresMapper();
            _service = new RaceService(
                _context,
                _mockSeriesService.Object,
                _mockBackgroundTaskQueue.Object,
                _mockLogger.Object,
                _mockServiceScopeFactory.Object,
                _mapper);

            _clubId = _context.Clubs.First().Id;
        }
示例#18
0
        private static int GetTriathletes(string raceId, int[] ageGroupIds, int[] genderIds)
        {
            using (var db = new RaceAnalysisDbContext())
            {
                var raceService = new RaceService(db);
                var athletes    = raceService.GetAthletes(
                    new BasicRaceCriteria
                {
                    SelectedRaceIds     = new string[] { raceId },
                    SelectedAgeGroupIds = ageGroupIds,
                    SelectedGenderIds   = genderIds
                },
                    false   /*do not use cache*/

                    );
                return(athletes.Count());
            }
        }
示例#19
0
 public void Initialize()
 {
     this._raceService = new RaceService(
         this._raceFileReaderMock.Object,
         this._raceRepositoryMock.Object,
         this._raceQueryMock.Object,
         this._raceTypeRepositoryMock.Object,
         this._raceTypeQueryMock.Object,
         this._userRepositoryMock.Object,
         this._userQueryMock.Object,
         this._lapRepositoryMock.Object,
         this._driverResultRepositoryMock.Object,
         this._driverResultQueryMock.Object,
         this._fileServerSettingsOptionsMock.Object,
         this._raceFileSettingsOptionsMock.Object,
         this._mapper
         );
 }
        public void DoWork_handles_ChangedData()
        {
            RacconHistory spiedHistory = null;

            var mockLogger = new Mock <ILogger>();

            var historyRepository = new Mock <IHistoryRepository>();

            historyRepository
            .Setup(h =>
                   h.InsertHistory(It.IsAny <RacconHistory>())
                   )
            .Callback <RacconHistory>((h) =>
            {
                spiedHistory = h;
            }
                                      )
            .Returns(1);

            var sut = new RaceService(mockLogger.Object, historyRepository.Object);

            var job = new Job {
                Entity         = eWiftEntity.Meeting,
                ChangeProperty = "StartTime",
                ChangeData     = new DateTime(2019, 11, 24, 14, 35, 0),
                SubjectName    = "Test Race 1",
                RaceId         = Guid.Parse("C56A4180-65AA-42EC-A945-5FD21DEC0538")
            };

            sut.DoWork(job);

            Assert.AreEqual("success", spiedHistory.status);
            Assert.AreEqual("Test Race 1", spiedHistory.subjectname);
            Assert.AreEqual("C56A4180-65AA-42EC-A945-5FD21DEC0538", spiedHistory.subjectkey.ToString().ToUpper());

            dynamic dyn = JsonConvert.DeserializeObject(spiedHistory.data);

            Assert.AreEqual("2019-11-24T14:35:00Z", dyn.postTime.ToString("yyyy-MM-ddTHH:mm:ssZ"));
        }
        public void TestAutomaticStartListCreation()
        {
            // Setup
            var skiers = new[] { new Skier(), new Skier(), new Skier() };

            var raceDaoMock = new Mock <IRaceDao>();
            var runDaoMock  = new Mock <IRunDao>();

            var daoProvider = DaoProviderHelper.GetPartialDaoProvider(
                raceDao: raceDaoMock.Object,
                runDao: runDaoMock.Object
                );
            var raceService = new RaceService(daoProvider);

            // Execute
            raceService.CreateRace(new Race(), skiers.ToList());

            // Assert
            runDaoMock.Verify(
                d => d.InsertMany(It.IsAny <IEnumerable <Run> >()),
                Times.Once()
                );
        }
        public void TestAutomaticInvertedStartListCreation()
        {
            // Setup
            var lastRunStatuses            = new[] { RunStatus.Completed, RunStatus.Disqualified, RunStatus.Completed };
            IEnumerable <Run> newRunsAdded = null;

            var raceDaoMock = new Mock <IRaceDao>();
            var runDaoMock  = new Mock <IRunDao>();

            runDaoMock.Setup(d => d.GetAllRunsForRace(It.IsAny <Race>(), It.IsAny <int>()))
            .Returns(Task.FromResult(
                         lastRunStatuses.Select(s => new Run {
                Status = s
            })
                         ));
            runDaoMock.Setup(d => d.InsertMany(It.IsAny <IEnumerable <Run> >()))
            .Callback <IEnumerable <Run> >(runs =>
                                           newRunsAdded = runs
                                           );

            var daoProvider = DaoProviderHelper.GetPartialDaoProvider(
                raceDao: raceDaoMock.Object,
                runDao: runDaoMock.Object
                );
            var raceService = new RaceService(daoProvider);

            // Execute
            raceService.CompleteRun(new Race(), 1);

            // Assert
            runDaoMock.Verify(
                d => d.InsertMany(It.IsAny <IEnumerable <Run> >()),
                Times.Once()
                );
            Assert.Equal(2, newRunsAdded.ToArray().Length);
        }
 public RaceParticipantController(ParticipantService participantService, GroupService groupService, RaceService raceService)
 {
     _participantService = participantService;
     _groupService       = groupService;
     _raceService        = raceService;
 }
        public IActionResult PostNewScore(ulong petid, int score)
        {
            var u = loginService.GetUserFromContext(HttpContext.User);

            if (u == null)
            {
                return(Unauthorized());
            }

            // get the pet
            var pet = petService.GetPetById(petid);

            if (pet == null)
            {
                return(NotFound());
            }
            // check ownership
            if (pet.UserId != u.UserId)
            {
                return(Unauthorized());
            }

            if (score <= 0)
            {
                return(BadRequest());
            }

            // TODO: Consider limiting this based on when the last score was inserted and when the last activity for this pet appears
            // could use the activity id as a way to do this.

            RaceService race = new RaceService(this.sqlManager);
            var         r    = race.InsertRace(new Race()
            {
                PetId     = petid,
                RaceId    = 0,
                Score     = score,
                Timestamp = DateTime.UtcNow
            });

            // also post a new activity
            activityService.MakeActivityForPet(petid, ActivityType.Race);

            // if the score was podium
            var rank = race.GetRaceRank(r.RaceId);

            if (rank != -1 && rank < 4)
            {
                activityService.MakeActivityForPet(petid, ActivityType.RaceHighScore);
                activityService.UpdatePetFromActivity(ActivityType.RaceHighScore, petid, petService);

                // new high score was posted
                var n = new NotificationService();
                if (u.PhoneNumber != null)
                {
                    n.SendMessage(u.PhoneNumber, $"Great job {u.Username}, you just placed #{rank} on the leaderboard!");
                }
                n.SendDiscordNotifyHighScore(rank, score, pet, u);
            }
            else
            {
                activityService.UpdatePetFromActivity(ActivityType.Race, petid, petService);
            }

            return(Json(r));
        }
 public RacesController(ApiContext context)
 {
     _raceRepository = new RaceRepository(context);
     _raceService    = new RaceService(context);
 }
 public RaceOverviewController(RaceService raceService)
 {
     _raceService = raceService;
 }
示例#27
0
 public ListarRaca()
 {
     InitializeComponent();
     ConfigurarDatagrid();
     raceService = new RaceService();
 }
示例#28
0
 public RaceController()
 {
     _PettypeService = new PettypeService();
     _raceService    = new RaceService();
 }
示例#29
0
 public RaceController()
 {
     this.raceService = new RaceService();
 }
示例#30
0
 public RacesController(RaceService raceService)
 {
     _raceService = raceService;
 }