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);
        }
Exemplo n.º 2
0
 public ActionResult Edit(RaceDetailsViewModel model)
 {
     _raceService.EditRace(model);
     return(RedirectToAction("Index"));
 }