public async Task VoteRepository_CRD_Tests() { const int firstWarId = 1234; const int secondWarId = 5678; var sqlServerConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WarDb"].ConnectionString; var repository = new VoteRepository(sqlServerConnectionString); var firstVote = await CreateVote(repository, firstWarId); var firstVoteWrongWarId = await repository.Get(secondWarId, firstVote.MatchId); firstVoteWrongWarId.Should().BeNullOrEmpty(); var secondVote = await CreateVote(repository, firstWarId); var thirdVote = await CreateVote(repository, secondWarId); var firstWarCollection = await repository.GetAll(firstWarId); VerifyVoteInCollection(firstWarCollection, firstVote); VerifyVoteInCollection(firstWarCollection, secondVote); VerifyVoteNotInCollection(firstWarCollection, thirdVote); var secondWarCollection = await repository.GetAll(secondWarId); VerifyVoteNotInCollection(secondWarCollection, firstVote); VerifyVoteNotInCollection(secondWarCollection, secondVote); VerifyVoteInCollection(secondWarCollection, thirdVote); await VerifyVoteDelete(repository, firstWarId, firstVote.MatchId); await VerifyVoteDelete(repository, firstWarId, secondVote.MatchId); await VerifyVoteDelete(repository, secondWarId, thirdVote.MatchId); }
public void Delete_Normal_Conditions() { var repo = new VoteRepository(); var vote = new Vote(); vote.OptionId = 2; vote.SurveyId = 3; var count = repo.GetAll().Count(); repo.Add(vote); repo.Delete(vote); Assert.IsTrue(repo.GetAll().Count() == count); }
public List <VoteDTO> GetAll() { List <VoteEntity> allvotes = ur.GetAll(); List <VoteDTO> l1 = Mapper.Map <List <VoteDTO> >(allvotes); return(l1); }
public async Task TestGetAllByCategory() { try { List <Vote> ans = (await voteRepository.GetAll(Context, DefaultElectionId, PresCategoryId)).ToList(); if (ans != null) { Assert.IsNotNull(ans, "Expected Vote from default dataset- Save a ballot to get votes back!"); } } catch (Exception ex) { Assert.IsNull(ex, "Exception Thrown: " + ex.Message); } }
/// <summary> /// Get API/Vote /// </summary> /// <returns>List de tous les Votes</returns> public IHttpActionResult Get() { if ((new[] { "Admin" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase)) { IEnumerable <VoteModel> List = repo.GetAll().Select(Vote => Vote?.ToModel()); if (List.Count() == 0) { return(NotFound()); } else { return(Json(List)); } } else { return(Unauthorized()); } }