Created
May 19, 2019 02:34
-
-
Save kctam/3e67966e0bffcc618ea5b18fbf82ac87 to your computer and use it in GitHub Desktop.
marketplace with no token
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
pragma solidity ^0.5.6; | |
import "ds-test/test.sol"; | |
import "./Emarket.sol"; | |
contract EmarketTest is DSTest { | |
Emarket emarket; | |
function setUp() public { | |
emarket = new Emarket(); | |
} | |
function testAddAnItem() public { | |
string memory desc_pen = "a pen"; | |
uint price_pen= 300; | |
emarket.addItem(desc_pen, price_pen); | |
string memory desc_book = "a book"; | |
uint price_book = 200; | |
emarket.addItem(desc_book, price_book); | |
assertTrue(emarket.itemCount() == 2); | |
} | |
function testGetItem() public { | |
string memory desc_pen = "a pen"; | |
uint price_pen= 300; | |
emarket.addItem(desc_pen, price_pen); | |
string memory desc; | |
uint price; | |
(desc, price) = emarket.getItem(1); | |
assertTrue(price == 300); | |
} | |
function testRemoveItem() public { | |
string memory desc_pen = "a pen"; | |
uint price_pen= 300; | |
emarket.addItem(desc_pen, price_pen); | |
string memory desc_book = "a book"; | |
uint price_book = 200; | |
emarket.addItem(desc_book, price_book); | |
assertTrue(emarket.checkItemExisting(1)); | |
emarket.removeItem(1); // remove item 1 | |
assertTrue(!emarket.checkItemExisting(1)); | |
} | |
function testBuyItem() public { | |
string memory desc_pen = "a pen"; | |
uint price_pen= 300; | |
emarket.addItem(desc_pen, price_pen); | |
assertTrue(!emarket.checkItemSold(1)); | |
emarket.buyItem(1); | |
assertTrue(emarket.checkItemSold(1)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment