public void ValidateDataEntry_GuestSeasonAndHostSeasonAreNotNull_ThrowsNoException() { // Arrange // Instantiate class under test. var viewModel = new GamePredictorWindowViewModel(_sharedService, _windowService) { GuestName = "Guest", HostName = "Host" }; // Set up needed infrastructure of class under test. A.CallTo(() => _sharedService.FindTeamSeason(viewModel.GuestName, viewModel.GuestSelectedSeason)) .Returns(new TeamSeason()); A.CallTo(() => _sharedService.FindTeamSeason(viewModel.HostName, viewModel.HostSelectedSeason)) .Returns(new TeamSeason()); // Act var result = viewModel.ValidateDataEntry(); // Assert A.CallTo(() => _sharedService.FindTeamSeason(viewModel.GuestName, viewModel.GuestSelectedSeason)) .MustHaveHappenedOnceExactly(); A.CallTo(() => _sharedService.FindTeamSeason(viewModel.HostName, viewModel.HostSelectedSeason)) .MustHaveHappenedOnceExactly(); Assert.IsInstanceOf <Matchup>(result); }
public void ValidateDataEntry_HostSeasonIsNull_ThrowsDataValidationException() { // Arrange // Instantiate class under test. var viewModel = new GamePredictorWindowViewModel(_sharedService, _windowService) { GuestName = "Guest", HostName = "Host" }; // Set up needed infrastructure of class under test. A.CallTo(() => _sharedService.FindTeamSeason(viewModel.GuestName, viewModel.GuestSelectedSeason)) .Returns(new TeamSeason()); A.CallTo(() => _sharedService.FindTeamSeason(viewModel.HostName, viewModel.HostSelectedSeason)) .Returns(null); // Act var ex = Assert.Throws <DataValidationException>(() => viewModel.ValidateDataEntry()); // Assert A.CallTo(() => _sharedService.FindTeamSeason(viewModel.GuestName, viewModel.GuestSelectedSeason)) .MustHaveHappenedOnceExactly(); A.CallTo(() => _sharedService.FindTeamSeason(viewModel.HostName, viewModel.HostSelectedSeason)) .MustHaveHappenedOnceExactly(); Assert.AreEqual(WpfGlobals.Constants.TeamNotInDatabaseMessage, ex.Message); }