public void ShouldGetResults() { //given var dictionary = new Dictionary <string, object> { { "HomeTeam", "Arsenal" }, { "AwayTeam", "Villa" }, { "HomeScore", 3 }, { "AwayScore", 0 }, { "HomeTeamId", 1 }, { "AwayTeamId", 2 }, { "ResultId", Guid.NewGuid() }, }; var helper = new Mock <IDbHelper>(); helper.Setup(x => x.ExecuteReader("up_RecentResults", null)).Returns( DataReaderTestHelper.Reader(dictionary)); var repository = new ResultsRepository(helper.Object); //when var resultsModels = repository.GetResults(); //then Assert.That(resultsModels.Count, Is.EqualTo(1)); Assert.That(resultsModels.First().AwayScore, Is.EqualTo(0)); Assert.That(resultsModels.First().AwayTeam, Is.EqualTo("Villa")); Assert.That(resultsModels.First().AwayTeamId, Is.EqualTo(2)); Assert.That(resultsModels.First().HomeScore, Is.EqualTo(3)); Assert.That(resultsModels.First().HomeTeam, Is.EqualTo("Arsenal")); Assert.That(resultsModels.First().HomeTeamId, Is.EqualTo(1)); Assert.That(resultsModels.First().ResultId, Is.EqualTo(dictionary["ResultId"])); }
public void ShouldGetPlayers() { var dictionary = new Dictionary <string, object> { { "UserId", 1 }, { "Name", "Arsenal" }, { "GoalsPerGame", 3.2f }, { "PointsPerGame", 4.2f }, { "MatchesPlayed", 1 } }; var helper = new Mock <IDbHelper>(); helper.Setup(x => x.ExecuteReader("up_GetTopPlayers", null)).Returns( DataReaderTestHelper.Reader(dictionary)); var repository = new PlayerRepository(helper.Object); //when var resultsModels = repository.GetTopPlayers(); //then Assert.That(resultsModels.Count, Is.EqualTo(1)); Assert.That(resultsModels.First().PointsPerGame, Is.EqualTo(4.2f)); Assert.That(resultsModels.First().GoalsPerGame, Is.EqualTo(3.2f)); Assert.That(resultsModels.First().PlayerName, Is.EqualTo("Arsenal")); Assert.That(resultsModels.First().MatchesPlayed, Is.EqualTo(1)); Assert.That(resultsModels.First().PlayerId, Is.EqualTo(1)); }
public void ShouldGetPlayerList() { //given var dictionary = new Dictionary <string, object> { { "UserId", 1 }, { "Name", "Arsenal" }, { "Surname", "Rajyaguru" }, { "Username", "hemdagem" }, { "UserType", 2 } }; var helper = new Mock <IDbHelper>(); helper.Setup(x => x.ExecuteReader("up_GetUsers", null)).Returns( DataReaderTestHelper.Reader(dictionary)); //when var repository = new PlayerRepository(helper.Object); var resultsModels = repository.GetAllPlayers(); //then Assert.That(resultsModels, Is.Not.Null); Assert.That(resultsModels.Count, Is.EqualTo(1)); Assert.That(resultsModels.First().PlayerName, Is.EqualTo("Arsenal")); Assert.That(resultsModels.First().PlayerId, Is.EqualTo(1)); }
public void ShouldGetEventInfoForGetEventMethod() { //given var dictionary = new Dictionary <string, object> { { "OwnerId", 10 }, { "TournamentName", "Event" }, { "Date", "10/10/2010" }, { "Completed", false }, { "TournamentType", TournamentType.Friendly }, }; var helper = new Mock <IDbHelper>(); helper.Setup(x => x.ExecuteReader("up_GetTournamentForEdit", It.IsAny <object>())).Returns( DataReaderTestHelper.Reader(dictionary)); var repository = new EventReadRepository(helper.Object); //when var eventId = Guid.NewGuid(); var eventModel = repository.GetEvent(eventId); //then Assert.IsNotNull(eventModel); Assert.That(eventModel.TournamentId, Is.EqualTo(eventId)); Assert.That(eventModel.OwnerId, Is.EqualTo(10)); Assert.That(eventModel.TournamentName, Is.EqualTo("Event")); Assert.That(eventModel.Date, Is.EqualTo("10/10/2010")); Assert.That(eventModel.Completed, Is.EqualTo(false)); Assert.That(eventModel.FixturesGenerated, Is.EqualTo(false)); Assert.That(eventModel.TournamentType, Is.EqualTo(TournamentType.Friendly)); }
public void ShouldGetListOfEventsForGetEventsMethod() { //given var dictionary = new Dictionary <string, object> { { "TournamentId", Guid.NewGuid() }, { "TournamentName", "Event" }, { "Date", "10/10/2010" }, { "Name", "Arsenal" }, { "Completed", true }, }; var helper = new Mock <IDbHelper>(); helper.Setup(x => x.ExecuteReader("up_GetTournamentDetails", null)).Returns( DataReaderTestHelper.Reader(dictionary)); var repository = new EventReadRepository(helper.Object); //when var resultsModels = repository.GetEvents(); //then Assert.That(resultsModels.Count, Is.EqualTo(1)); Assert.That(resultsModels.First().TournamentId, Is.EqualTo(dictionary["TournamentId"])); Assert.That(resultsModels.First().TournamentName, Is.EqualTo("Event")); Assert.That(resultsModels.First().Date, Is.EqualTo("10/10/2010")); Assert.That(resultsModels.First().Name, Is.EqualTo("Arsenal")); Assert.That(resultsModels.First().Completed, Is.EqualTo(true)); }
public void ShouldThrowExceptionIfRowsPerPageIsLessThanOne() { var dictionary = new Dictionary <string, object> { { "Id", 1 }, { "Name", "Arsenal" }, { "GoalsPerGame", 3.2f }, { "PointsPerGame", 4.2f }, { "MatchesPlayed", 1 } }; var helper = new Mock <IDbHelper>(); helper.Setup(x => x.ExecuteReader(It.IsAny <string>(), null)).Returns( DataReaderTestHelper.Reader(dictionary)); var repository = new PlayerRepository(helper.Object); //when Assert.Throws <Exception>(() => repository.GetTopPlayersRange(1, 0)); }
public void ShouldGetStandardUser() { //given Setup(); _helper.Setup(x => x.ExecuteReader("up_GetLoginDetails", It.IsAny <object>())).Returns(DataReaderTestHelper.Reader(_dictionary)); //when var user = _repository.GetUser(It.IsAny <string>()); //then Assert.That(user, Is.Not.Null); Assert.That(user.UserId, Is.EqualTo(1)); Assert.That(user.Forename, Is.EqualTo("Hemang")); Assert.That(user.Surname, Is.EqualTo("Rajyaguru")); Assert.That(user.Username, Is.EqualTo("hemdagem")); Assert.That(user.UserType, Is.EqualTo((int)UserType.Standard)); }