-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from Pier-Two/dev
Add NUnit tests
- Loading branch information
Showing
12 changed files
with
407 additions
and
44 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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,46 @@ | ||
using System.Reflection; | ||
using Lantern.Beacon.Networking.Libp2pProtocols.Identify; | ||
using Moq; | ||
using Nethermind.Libp2p.Core; | ||
using NUnit.Framework; | ||
|
||
namespace Lantern.Beacon.Tests; | ||
|
||
[TestFixture] | ||
public class BeaconClientPeerFactoryTests | ||
{ | ||
private BeaconClientPeerFactory _beaconClientPeerFactory; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_beaconClientPeerFactory = new BeaconClientPeerFactory(null); | ||
} | ||
|
||
[Test] | ||
public async Task ConnectedTo_ShouldDialPeerIdentifyProtocol() | ||
{ | ||
var mockRemotePeer = new Mock<IRemotePeer>(); | ||
var method = typeof(BeaconClientPeerFactory).GetMethod("ConnectedTo", BindingFlags.NonPublic | BindingFlags.Instance); | ||
|
||
if (method == null) | ||
{ | ||
Assert.Fail("The method 'ConnectedTo' was not found."); | ||
} | ||
else | ||
{ | ||
var task = (Task)method.Invoke(_beaconClientPeerFactory, [mockRemotePeer.Object, true]); | ||
await task; | ||
} | ||
|
||
mockRemotePeer.Verify(x => x.DialAsync<PeerIdentifyProtocol>(new CancellationToken()), Times.Once()); | ||
} | ||
|
||
[Test] | ||
public void Create_ShouldReturnLocalPeer() | ||
{ | ||
var localPeer = _beaconClientPeerFactory.Create(); | ||
|
||
Assert.That(localPeer, Is.Not.Null); | ||
} | ||
} |
Oops, something went wrong.