forked from aloisdg/Ether.Network
-
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.
- Loading branch information
Filipe GOMES PEIXOTO
committed
Feb 21, 2018
1 parent
d917192
commit 2e920e6
Showing
3 changed files
with
115 additions
and
1 deletion.
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
42 changes: 42 additions & 0 deletions
42
test/Ether.Network.Tests/Contexts/NetConfig/ConfigServer.cs
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,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Ether.Network.Common; | ||
using Ether.Network.Server; | ||
|
||
namespace Ether.Network.Tests.Contexts.NetConfig | ||
{ | ||
public class ConfigServer : NetServer<Client> | ||
{ | ||
protected override void Initialize() | ||
{ | ||
} | ||
|
||
protected override void OnClientConnected(Client connection) | ||
{ | ||
} | ||
|
||
protected override void OnClientDisconnected(Client connection) | ||
{ | ||
} | ||
|
||
protected override void OnError(Exception exception) | ||
{ | ||
} | ||
|
||
public void SetupConfiguration() | ||
{ | ||
this.Configuration.BufferSize = 512; | ||
this.Configuration.MaximumNumberOfConnections = 10; | ||
this.Configuration.Host = "127.0.0.1"; | ||
this.Configuration.Port = 4444; | ||
this.Configuration.Backlog = 10; | ||
this.Configuration.Blocking = false; | ||
} | ||
} | ||
|
||
public class Client : NetUser | ||
{ | ||
|
||
} | ||
} |
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,65 @@ | ||
using Ether.Network.Exceptions; | ||
using Ether.Network.Tests.Contexts.NetConfig; | ||
using System; | ||
using Xunit; | ||
|
||
namespace Ether.Network.Tests | ||
{ | ||
public class NetServerConfigurationTest | ||
{ | ||
[Fact] | ||
public void StartServerWithoutConfiguration() | ||
{ | ||
using (var server = new ConfigServer()) | ||
{ | ||
Exception ex = Assert.Throws<EtherConfigurationException>(() => server.Start()); | ||
|
||
Assert.IsType<EtherConfigurationException>(ex); | ||
|
||
server.Stop(); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void SetupServerConfigurationBeforeStart() | ||
{ | ||
using (var server = new ConfigServer()) | ||
{ | ||
server.SetupConfiguration(); | ||
server.Start(); | ||
server.Stop(); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void SetupServerConfigurationAfterStart() | ||
{ | ||
using (var server = new ConfigServer()) | ||
{ | ||
server.SetupConfiguration(); | ||
server.Start(); | ||
|
||
Exception ex = Assert.Throws<EtherConfigurationException>(() => server.SetupConfiguration()); | ||
|
||
Assert.IsType<EtherConfigurationException>(ex); | ||
|
||
server.Stop(); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void SetupServerConfigurationAfterStartStop() | ||
{ | ||
using (var server = new ConfigServer()) | ||
{ | ||
server.SetupConfiguration(); | ||
server.Start(); | ||
server.Stop(); | ||
|
||
server.SetupConfiguration(); | ||
server.Start(); | ||
server.Stop(); | ||
} | ||
} | ||
} | ||
} |