Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed each test to have arrange/act/assert #28

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions CLVMDotNet/tests/CLVM/CLVMObject/InstantiationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ public class InstantiationTests
[InlineData(0x03, 0x03)]
public void Constructor_with_tuple_sets_pair(dynamic? left, dynamic? right)
{
// Arrange
Tuple<dynamic?, dynamic?> tuple = new Tuple<dynamic?, dynamic?>(left, right);

// Act
var clvmobject = new x.CLVMObject(tuple);

// Assert
Assert.NotNull(clvmobject.Pair);
Assert.Null(clvmobject.Atom);
}
Expand All @@ -25,39 +30,52 @@ public void Constructor_with_tuple_sets_pair(dynamic? left, dynamic? right)
[InlineData(0x03)]
public void Constructor_with_atom_sets_atom(dynamic atom)
{
// Arrange

// Act
var clvmobject = new x.CLVMObject(atom);

// Assert
Assert.NotNull(clvmobject.Atom);
Assert.Null(clvmobject.Pair);
}

[Fact]
public void Constructor_with_sexp_sets_atom()
{
// Arrange
var sexp = x.SExp.To(0x03);

// Act
var clvmobject = new x.CLVMObject(sexp);

// Assert
Assert.NotNull(clvmobject.Atom);
Assert.Null(clvmobject.Pair);
}

[Fact]
public void Constructor_with_invalid_tuple_shape()
{
// Arrange

// Act
var errorLength3 =
Assert.Throws<ArgumentException>(() =>
new x.CLVMObject((1, 2, 3))
);
Assert.Contains("tuples must be of size 2", errorLength3.Message);

var errorLength4 =
Assert.Throws<ArgumentException>(() =>
new x.CLVMObject((1, 2, 3, 4))
);
Assert.Contains("tuples must be of size 2", errorLength4.Message);

var errorLength5 =
Assert.Throws<ArgumentException>(() =>
new x.CLVMObject((1, 2, 3, 4, 5))
);

// Assert
Assert.Contains("tuples must be of size 2", errorLength3.Message);
Assert.Contains("tuples must be of size 2", errorLength4.Message);
Assert.Contains("tuples must be of size 2", errorLength5.Message);
}
}
5 changes: 5 additions & 0 deletions CLVMDotNet/tests/CLVM/Casts/IntFromBytes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ public class IntFromBytes
[InlineData("20482048204820482048", new byte[] { 0x01, 0x1C, 0x3E, 0xDA, 0x52, 0xE0, 0xC0, 0x88, 0x00 })]
public void IntFromBytes_returns_expectedint(string expectedNumberStr, byte[] from_bytes)
{
// Arrange
BigInteger expectedNumber = BigInteger.Parse(expectedNumberStr);

// Act
var returnedBytes = x.Casts.IntFromBytes(from_bytes);

// Assert
Assert.Equal(expectedNumber, returnedBytes);
}
}
Expand Down
5 changes: 5 additions & 0 deletions CLVMDotNet/tests/CLVM/Casts/IntToBytes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ public class IntToBytes
// })]
public void IntToBytes_returns_expectedbytes(string numberStr, byte[] expectedBytes)
{
// Arrange
BigInteger number = BigInteger.Parse(numberStr);

// Act
var returnedBytes = x.Casts.IntToBytes(number);

// Assert
Assert.Equal(expectedBytes, returnedBytes);
}
}
Expand Down
5 changes: 5 additions & 0 deletions CLVMDotNet/tests/CLVM/Casts/LimbsForInt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ public class LimbsForInt
[InlineData("20482048204820482048", 9)]
public void LimbsForInt_returns_expectedlength(string numStr, int expectedNumberOfBytes)
{
// Arrange
BigInteger num = BigInteger.Parse(numStr);

// Act
var numberOfBytes = x.Casts.LimbsForInt(num);

// Assert
Assert.Equal(expectedNumberOfBytes, numberOfBytes);
}
}
Expand Down
8 changes: 7 additions & 1 deletion CLVMDotNet/tests/CLVM/HelperFunctions/MSBMask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ public class MSBMask
[InlineData(0x80, 0xFF)]
public void TestMsbMask(byte expectedbyte, byte MSB)
{
Assert.Equal(expectedbyte, x.HelperFunctions.MSBMask(MSB));
// Arrange

// Act
var result = x.HelperFunctions.MSBMask(MSB);

// Assert
Assert.Equal(expectedbyte, result);
}
}
}
Loading
Loading