Ejemplo n.º 1
0
        public async Task TestInsertUpdateVote()
        {
            try
            {
                // now add a vote for candidate1
                Vote vote = new Vote()
                {
                    ElectionId     = DefaultElectionId,
                    BallotId       = Guid.NewGuid(),
                    CategoryId     = PresCategoryId,
                    CategoryTypeId = 2,
                    SelectionId    = BidenTicketId,
                    VoteStatus     = 0,
                    ApprovalDate   = DateTime.Now
                };
                UOW.BeginTransaction();
                Vote inserted = await voteRepository.Insert(UOW, vote);

                Assert.IsNotNull(inserted);
                Assert.IsTrue(inserted.Id != Guid.Empty, "Expect inserted vote Id not be empty");
                // now change the ballot selection to candidate2
                vote.Id         = inserted.Id;
                vote.VoteStatus = (int)VoteStatusEnum.choiceRejected;

                Vote updated = await voteRepository.Update(UOW, vote);

                Assert.IsNotNull(updated);
                Assert.IsTrue(inserted.Id == updated.Id, "Expect inserted and updated Id to be the same");
                UOW.CloseTransaction();
            }
            catch (Exception ex)
            {
                Assert.IsNull(ex, "Exception Thrown: " + ex.Message);
            }
        }