public void AccumulateForRoot_IfAccumulateIsPRIVATE_METHOD() { //Create a BODVotingCard var card1 = new VotingCard(_shareHolder, _candidates, VotingCardType.BODVotingCard); card1.IsVoted = true; //Create BODVotingCard List var votingCards = new List <VotingCard>(); votingCards.Add(card1); //Set argument for constructor var types = new Type[] { typeof(List <Candidate>), typeof(VotingCardType) }; var values = new Object[] { _candidates, VotingCardType.BODVotingCard }; //Create instance using arguments above PrivateObject sut = new PrivateObject(typeof(VotingResultView), types, values); sut.Invoke("AccumulateForRoot", votingCards); //Assert properties Assert.AreEqual(1, sut.GetProperty("NumberOfVotingCardsIssured")); Assert.AreEqual(1, sut.GetProperty("NumberOfVotingCardsReceived")); Assert.AreEqual(1, sut.GetProperty("NumberOfVotingCardsValidated")); Assert.AreEqual(0, sut.GetProperty("NumberOfVotingCardNotReceived")); Assert.AreEqual(2000, sut.GetProperty("VotingCardAmtIssured")); Assert.AreEqual(2000, sut.GetProperty("VotingCardAmtReceived")); Assert.AreEqual(0, sut.GetProperty("VotingCardAmtNotReceived")); Assert.AreEqual(100M, sut.GetProperty("VotingCardAmtReceivedRate")); Assert.AreEqual(0M, sut.GetProperty("VotingCardAmtNotReceivedRate")); }
public void AccumulateForCandidate_OneVotingCardVotedTheSameForEachCandidate() { //Create Voted BODVotingCard var card1 = new VotingCard(_shareHolder, _candidates, VotingCardType.BODVotingCard); card1.IsVoted = true; foreach (var item in card1.VotingCardLines) { item.VotingAmt = 1000; } //Create Voted BODVotingCard List var votingCards = new List <VotingCard>(); votingCards.Add(card1); //Action var sut = new VotingResultView(_candidates, VotingCardType.BODVotingCard); sut.AccumulateForCandidate(votingCards); //Assert foreach (var candidate in sut.CandidateLines) { Assert.AreEqual(1000, candidate.TotalVoting); } }
public void AccumulateForRoot_TwoVotingCardAndReceiveOneValidVotingCard() { //Create two Voted BODVotingCards, the second is NOT VOTED var card1 = new VotingCard(_shareHolder, _candidates, VotingCardType.BODVotingCard); card1.IsVoted = true; var card2 = new VotingCard(_shareHolder, _candidates, VotingCardType.BODVotingCard); card2.IsVoted = false; //BODVotingCard List var votingCards = new List <VotingCard>(); votingCards.Add(card1); votingCards.Add(card2); //Act var sut = new VotingResultView(_candidates, VotingCardType.BODVotingCard); sut.AccumulateForRoot(votingCards); // Assert.AreEqual(2, sut.NumberOfVotingCardsIssured); Assert.AreEqual(1, sut.NumberOfVotingCardsReceived); Assert.AreEqual(1, sut.NumberOfVotingCardsValidated); Assert.AreEqual(1, sut.NumberOfVotingCardNotReceived); Assert.AreEqual(4000, sut.VotingCardAmtIssured); Assert.AreEqual(2000, sut.VotingCardAmtReceived); Assert.AreEqual(2000, sut.VotingCardAmtNotReceived); Assert.AreEqual(50, sut.VotingCardAmtReceivedRate); Assert.AreEqual(50, sut.VotingCardAmtNotReceivedRate); }
public void AccumulateForRoot_OneVotingCardAndReceiveOneValidVotingCard() { //Create a BODVotingCard var card1 = new VotingCard(_shareHolder, _candidates, VotingCardType.BODVotingCard); card1.IsVoted = true; //Create BODVotingCard List var votingCards = new List <VotingCard>(); votingCards.Add(card1); var sut = new VotingResultView(_candidates, VotingCardType.BODVotingCard); sut.AccumulateForRoot(votingCards); Assert.AreEqual(1, sut.NumberOfVotingCardsIssured); Assert.AreEqual(1, sut.NumberOfVotingCardsReceived); Assert.AreEqual(1, sut.NumberOfVotingCardsValidated); Assert.AreEqual(0, sut.NumberOfVotingCardNotReceived); Assert.AreEqual(2000, sut.VotingCardAmtIssured); Assert.AreEqual(2000, sut.VotingCardAmtReceived); Assert.AreEqual(0, sut.VotingCardAmtNotReceived); Assert.AreEqual(100M, sut.VotingCardAmtReceivedRate); Assert.AreEqual(0M, sut.VotingCardAmtNotReceivedRate); }
public void InsertOrUpdate(VotingCard entity) { if (entity.Id == default(int)) { // New entity _context.VotingCards.Add(entity); } else { // Existing entity _context.Entry(entity).State = System.Data.Entity.EntityState.Modified; } }
public void UpdateGraph(VotingCard entity) { if (_context != null) { _context.Entry(entity).State = System.Data.Entity.EntityState.Modified; } foreach (var line in entity.VotingCardLines) { if (line.Id == default(int)) { _context.Entry(line).State = System.Data.Entity.EntityState.Added; } else { _context.Entry(line).State = System.Data.Entity.EntityState.Modified; } } }
public void CreateVotingCard_VotingCardLineIsEqualToTWO() { var sut = new VotingCard(_shareHolder, _candidates, VotingCardType.BODVotingCard); Assert.AreEqual(2, sut.VotingCardLines.Count); }
public void CreateVotingCard_WhenShareHolderIsABSENT_RaiseException() { _shareHolder.StatusAtMeeting = StatusAtMeeting.Absent; var sut = new VotingCard(_shareHolder, _candidates, VotingCardType.BODVotingCard); //Assert.IsNotNull(sut); }
public void CreateVotingCard_ReturnNotNull() { var sut = new VotingCard(_shareHolder, _candidates, VotingCardType.BODVotingCard); Assert.IsNotNull(sut); }