public async Task StartRaffleWithoutEntrants() { await RaffleService.StartRaffle(false); Modal.Close(ModalResult.Ok(this)); StateHasChanged(); }
private async Task InitializeServices() { await InitalizeSignalRAsync(); if (RaffleService.LatestRaffle == null) { await RaffleService.InitializeService(); } }
protected async Task StopRaffle() { Console.WriteLine($"{DateTime.Now}: Stopping the Raffle"); await RaffleService.StopRaffle(); Console.WriteLine($"{DateTime.Now}: Stopped the Raffle"); ToggleEnabledButtons(true, false, true); StateHasChanged(); }
protected async Task SelectRaffleWinner() { Console.WriteLine($"{DateTime.Now}: Selecting a raffle winner"); var result = await RaffleService.SelectRaffleWinner(); Console.WriteLine($"{DateTime.Now}: Resulting SID from notifying winner - {result}"); Console.WriteLine($"{DateTime.Now}: Selected a raffle winner"); ToggleEnabledButtons(true, false, false); StateHasChanged(); }
public async Task StartRaffleAsync_CurrentRaffleRunning_ThrowsApplicationException() { // arrange _currentRaffle.State = RaffleState.Running; var svc = new RaffleService(_updaterMock.Object, _prizeServiceMock.Object, _configMock.Object, _loggerMock.Object) { LatestRaffle = _currentRaffle }; // act // assert await Assert.ThrowsExceptionAsync <ApplicationException>(async() => await svc.StartRaffle()); }
public async Task AddRaffleEntry_ToNotRunningRaffle_WithValidEntry_ReturnNull() { // arrange _currentRaffle = new Raffle { State = RaffleState.NotRunning }; _currentRaffleEntry = new RaffleEntry(); var svc = new RaffleService(_updaterMock.Object, _prizeServiceMock.Object, _configMock.Object, _loggerMock.Object) { LatestRaffle = _currentRaffle }; // act var result = await svc.AddRaffleEntry(_currentRaffleEntry); // assert // TODO: Update ASSERT for Adding a Raffle Entry to a Not Running Assert.IsNotNull(result); }
public async Task StartRaffleAsync_CurrentRaffleNotRunning_ReturnsValidId() { // arrange _currentRaffle.State = RaffleState.NotRunning; _updaterMock .Setup(updater => updater.CreateRaffle(It.IsAny <string>(), It.IsAny <Raffle>())) .ReturnsAsync(new object()); var svc = new RaffleService(_updaterMock.Object, _prizeServiceMock.Object, _configMock.Object, _loggerMock.Object) { LatestRaffle = _currentRaffle }; // act await svc.StartRaffle(); // assert Assert.IsTrue(_currentRaffle.State == RaffleState.Running); }
public async Task AddRaffleEntry_ToRunningRaffle_WithValidEntry_ReturnsValidId() { // arrange _currentRaffle.State = RaffleState.Running; _updaterMock .Setup(updater => updater.UpdateRaffle(It.IsAny <Raffle>())) .Returns(async() => await Task.CompletedTask); var svc = new RaffleService(_updaterMock.Object, _prizeServiceMock.Object, _configMock.Object, _loggerMock.Object) { LatestRaffle = _currentRaffle }; // act await svc.AddRaffleEntry(_currentRaffleEntry); // assert Assert.IsTrue(_currentRaffle.Entries.Count == 1); Assert.AreEqual(_currentRaffle.Entries[0], _currentRaffleEntry); }
protected async Task ClearRaffles() { await RaffleService.ClearRaffles(); }