コード例 #1
0
        public async Task StartRaffleWithoutEntrants()
        {
            await RaffleService.StartRaffle(false);

            Modal.Close(ModalResult.Ok(this));
            StateHasChanged();
        }
コード例 #2
0
        private async Task InitializeServices()
        {
            await InitalizeSignalRAsync();

            if (RaffleService.LatestRaffle == null)
            {
                await RaffleService.InitializeService();
            }
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
 protected async Task ClearRaffles()
 {
     await RaffleService.ClearRaffles();
 }