Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c79f78
commit d3887bd
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
pragma solidity >=0.4.22 <0.8.0; | ||
|
||
import "truffle/Assert.sol"; | ||
import "truffle/DeployedAddresses.sol"; | ||
import "../contracts/Voting.sol"; | ||
|
||
contract TestVoting { | ||
Voting voting = Voting(DeployedAddresses.Voting()); | ||
|
||
uint256 expectedLocationId = 8; | ||
|
||
address expectedVotedLocation = address(this); | ||
|
||
function testUserCanVoteLocation() public { | ||
uint256 returnedId = voting.vote(expectedLocationId); | ||
|
||
Assert.equal( | ||
returnedId, | ||
expectedLocationId, | ||
"User was able to vote for the expected location and expectedVotedLocation should match what is returned." | ||
); | ||
} | ||
|
||
function testGetVotedLocationAddressByLocationId() public { | ||
address location = voting.locations(expectedLocationId); | ||
|
||
Assert.equal( | ||
location, | ||
expectedVotedLocation, | ||
"Voted Location of the expected location should be this contract" | ||
); | ||
} | ||
|
||
function testGetVotedLocationAddressByLocationIdInArray() public { | ||
address[16] memory locations = voting.getLocations(); | ||
|
||
Assert.equal( | ||
locations[expectedLocationId], | ||
expectedVotedLocation, | ||
"Voted location of the expected location should be this contract" | ||
); | ||
} | ||
} |