-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathSimpleStorageTest.t.sol
36 lines (30 loc) · 1.05 KB
/
SimpleStorageTest.t.sol
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
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import {DeploySimpleStorage} from "../script/DeploySimpleStorage.s.sol";
import {SimpleStorage} from "../src/SimpleStorage.sol";
import {Test} from "forge-std/Test.sol";
contract SimpleStorageTest is Test {
SimpleStorage public simpleStorage;
function setUp() external {
DeploySimpleStorage deployer = new DeploySimpleStorage();
simpleStorage = deployer.run();
}
function testStoreNumber() public {
// Arrange
uint256 expectedFavoiteNumber = 777;
// Act
simpleStorage.store(expectedFavoiteNumber);
// Assert
assert(expectedFavoiteNumber == simpleStorage.retrieve());
}
function testCreatePerson() public {
// Arrange
string memory name = "Jon";
uint256 expectedNumber = 25;
// Act
simpleStorage.addPerson(name, expectedNumber);
// Assert
uint256 retreievedNumber = simpleStorage.nameToFavoriteNumber(name);
assert(retreievedNumber == expectedNumber);
}
}