-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed project 'Tests' to 'Anarchy.Tests'
- Loading branch information
1 parent
5776b78
commit 61af228
Showing
18 changed files
with
132 additions
and
388 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<BaseIntermediateOutputPath>..\.obj\Anarchy.Tests</BaseIntermediateOutputPath> | ||
<MSBuildProjectExtensionsPath>..\.obj\Anarchy.Tests</MSBuildProjectExtensionsPath> | ||
</PropertyGroup> | ||
</Project> |
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,54 @@ | ||
using System.Text; | ||
using Microsoft.Maui.Graphics; | ||
|
||
namespace Discord | ||
{ | ||
[TestClass] | ||
public class AttachmentTests | ||
{ | ||
[TestMethod] | ||
public void SendFile() | ||
{ | ||
var client = Globals.Client; | ||
var channelId = Globals.Settings.ChannelId; | ||
|
||
var msg = client.SendFile(channelId, Globals.FileNames.PoetryTxt, $"{nameof(SendFile)} attachment test."); | ||
|
||
Assert.AreEqual(1, msg.Attachments.Count); | ||
} | ||
|
||
[TestMethod] | ||
public void SendMessageProperties() | ||
{ | ||
var image1 = DiscordImageSource.FromStream(File.OpenRead(Globals.FileNames.Image1), ImageFormat.Png); | ||
var image2 = DiscordImageSource.FromStream(File.OpenRead(Globals.FileNames.Image2), ImageFormat.Jpeg); | ||
var poetryText = File.ReadAllText(Globals.FileNames.PoetryTxt); | ||
|
||
var props = new MessageProperties | ||
{ | ||
Content = $"{nameof(MessageProperties)} attachment test.", | ||
Attachments = new List<PartialDiscordAttachment>() | ||
{ | ||
// Attach an arbitrary file. | ||
new PartialDiscordAttachment(Globals.FileNames.Image1), | ||
// Attach an existing DiscordImage. | ||
new PartialDiscordAttachment(image2, Globals.FileNames.Image2), | ||
// Attach an arbitrary file with custom specifications for everything. | ||
new PartialDiscordAttachment( | ||
new DiscordAttachmentFile(Encoding.UTF8.GetBytes(poetryText), MediaTypeNames.Text.Plain), | ||
Globals.FileNames.PoetryTxt, | ||
"Text File") | ||
} | ||
}; | ||
|
||
var client = Globals.Client; | ||
var channelId = Globals.Settings.ChannelId; | ||
|
||
var msg = client.SendMessage(channelId, props); | ||
Assert.AreEqual(props.Attachments.Count, msg.Attachments.Count); | ||
|
||
var postedImage1 = DiscordImageSource.FromUrl(msg.Attachments[0].Url).Result; | ||
CollectionAssert.AreEqual(postedImage1.PlatformImage.Bytes, image1.PlatformImage.Bytes); | ||
} | ||
} | ||
} |
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,18 @@ | ||
namespace Discord | ||
{ | ||
[TestClass] | ||
public class MessageTests | ||
{ | ||
[TestMethod] | ||
public void SendMessage() | ||
{ | ||
const string content = "The simplest possible message."; | ||
|
||
var msg = Globals.Client.SendMessage( | ||
Globals.Settings.ChannelId, | ||
content); | ||
|
||
Assert.AreEqual(content, msg.Content); | ||
} | ||
} | ||
} |
File renamed without changes
File renamed without changes
File renamed without changes.
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,9 @@ | ||
namespace Discord.Settings | ||
{ | ||
internal class App | ||
{ | ||
public string Token { get; set; } = string.Empty; | ||
public ulong ChannelId { get; set; } | ||
public ProxySettings? Proxy { get; set; } | ||
} | ||
} |
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,15 @@ | ||
using System.Net; | ||
|
||
namespace Discord.Settings | ||
{ | ||
internal class ProxySettings | ||
{ | ||
public string Host { get; set; } = String.Empty; | ||
public int Port { get; set; } | ||
|
||
public IWebProxy CreateProxy() | ||
{ | ||
return new WebProxy(Host, Port); | ||
} | ||
} | ||
} |
File renamed without changes.
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,4 @@ | ||
{ | ||
"Token": "<string: A discord user token>", | ||
"ChannelId": "<ulong: The discord channel ID the unit tests will post to. The user identified by 'Token' must have access to this channel." | ||
} |
Oops, something went wrong.