generated from stho32/BP001-ProjectTemplate-Base
-
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.
17 remove the usage of webclientwebclient (#18)
* Refactored the LnacClient (once Server) as the utility to access the server-api. There is now additionally an accessor for the specific method "WebApi". * Increased test coverage for the server side. Extracted access control to separate class. * Added test coverage for MessageProcessing * Server Domain has now 100% test Coverage * Test coverage for Result-Class * Excluding test coverage for several classes where unit tests are not helpful
- Loading branch information
Showing
39 changed files
with
750 additions
and
272 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
17 changes: 17 additions & 0 deletions
17
Source/LocalNetAppChat/LocalNetAppChat.Domain.Tests/Shared/CommandMessageTokenizerTests.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,17 @@ | ||
using LocalNetAppChat.Domain.Shared; | ||
using NUnit.Framework; | ||
|
||
namespace LocalNetAppChat.Domain.Tests.Shared; | ||
|
||
[TestFixture] | ||
public class CommandMessageTokenizerTests | ||
{ | ||
[Test] | ||
public void When_in_the_message_there_is_no_space_left_the_rest_is_the_token() | ||
{ | ||
var message= "token"; | ||
var token = CommandMessageTokenizer.GetToken(ref message); | ||
Assert.AreEqual("token", token); | ||
Assert.AreEqual("", message); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ce/LocalNetAppChat/LocalNetAppChat.Domain.Tests/Shared/MessageForDisplayFormatterTests.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,36 @@ | ||
using LocalNetAppChat.Domain.Shared; | ||
using NUnit.Framework; | ||
|
||
namespace LocalNetAppChat.Domain.Tests.Shared; | ||
|
||
[TestFixture] | ||
public class MessageForDisplayFormatterTests | ||
{ | ||
private string GetFormattedMessage(string receiverPrivateMessage) | ||
{ | ||
var message = new ReceivedMessage(0, new DateTime(2023, 2, 1, 1, 2, 3), | ||
receiverPrivateMessage, | ||
new LnacMessage("Id", "Name", "Text", Array.Empty<string>(), true, "Message") | ||
); | ||
|
||
var result = MessageForDisplayFormatter.GetTextFor(message); | ||
|
||
return result; | ||
} | ||
|
||
[Test] | ||
public void Normal_message_format_is_correct() | ||
{ | ||
var result = GetFormattedMessage(string.Empty); | ||
|
||
Assert.AreEqual(" - [2023-02-01 01:02:03] Name: Text", result); | ||
} | ||
|
||
[Test] | ||
public void Private_message_format_is_correct() | ||
{ | ||
var result = GetFormattedMessage("Receiver"); | ||
|
||
Assert.AreEqual(" - [2023-02-01 01:02:03] *PRIVATEMSG* Name: Text", result); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Source/LocalNetAppChat/LocalNetAppChat.Domain.Tests/Shared/ResultTests.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,24 @@ | ||
using LocalNetAppChat.Domain.Shared; | ||
using NUnit.Framework; | ||
|
||
namespace LocalNetAppChat.Domain.Tests.Shared; | ||
|
||
[TestFixture] | ||
public class ResultTests | ||
{ | ||
[Test] | ||
public void When_Result_is_successful_but_without_value_an_exception_is_thrown() | ||
{ | ||
Assert.Throws<ArgumentNullException>( | ||
() => Result<string>.Success(null) | ||
); | ||
} | ||
|
||
[Test] | ||
public void When_Result_is_not_Successful_the_error_is_not_empty() | ||
{ | ||
Assert.Throws<ArgumentException>( | ||
() => Result<string>.Failure(null) | ||
); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Source/LocalNetAppChat/LocalNetAppChat.Domain/Clientside/ClientSideCommandLineParameters.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
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
11 changes: 11 additions & 0 deletions
11
Source/LocalNetAppChat/LocalNetAppChat.Domain/Clientside/ServerApis/IServerApiAccessor.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,11 @@ | ||
namespace LocalNetAppChat.Domain.Clientside; | ||
|
||
public interface IServerApiAccessor | ||
{ | ||
Task<string> GetAsync(string command); | ||
Task<string> PostAsync(string command, Dictionary<string, string> parameters); | ||
|
||
Task<string> PostAsJsonAsync(string command, object data); | ||
Task<string> PostFileAsync(string command, string filename, Stream fileStream); | ||
Task<Stream> GetFileAsync(string command, string filename); | ||
} |
Oops, something went wrong.