1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| pragma solidity ^0.4.4;
import "truffle/Assert.sol"; import "truffle/DeployedAddress.sol"; import "../contracts/Adoption.sol";
contract TestAdoption { Adoption adoption = Adoption(DeployedAddress.Adoption()); function testUserCanAdoptPet () { uint returnedPetId = adoption.adopt(8); uint expected = 8; Assert.equal(returenedPetId, expected, "Adoption of Pet Id 8 should be recorded"); }
function testGetAdopterAddressByPetId () { address expected = this; address adopter = adoption.adopters(8); Assert.equal(adopter, expected, "Owner of Pet Id 8 should be recorded"); }
function testGetAdopterAddressByPetIdInArray () { address expected = this; address[16] memory adopters = adoption.getAdopters(); Assert(expected, adopters[8], "Owner of Pet Id 8 should be recoreded"); } }
|