Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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
82 changes: 0 additions & 82 deletions Code2Gether-Discord-Bot.Tests/CreateProjectTests.cs

This file was deleted.

46 changes: 2 additions & 44 deletions Code2Gether-Discord-Bot.Tests/ExcuseGeneratorTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System.Threading.Tasks;
using Code2Gether_Discord_Bot.Library.BusinessLogic;
using Code2Gether_Discord_Bot.Library.Models;
using Code2Gether_Discord_Bot.Static;
using Code2Gether_Discord_Bot.Tests.Fakes;
using NUnit.Framework;

namespace Code2Gether_Discord_Bot.Tests
Expand All @@ -12,47 +9,8 @@ internal class ExcuseGeneratorTest
IBusinessLogic _logic;

[SetUp]
public void Setup()
{
var user = new FakeUser()
{
Username = "UnitTest",
DiscriminatorValue = 1234,
Id = 123456789123456789
};

var client = new FakeDiscordClient()
{
FakeApplication = new FakeApplication()
{
Owner = user
}
};

var guild = new FakeGuild()
{

};

var messageChannel = new FakeMessageChannel()
{

};

var message = new FakeUserMessage()
{
Author = user
};

_logic = BusinessLogicFactory.ExcuseGeneratorLogic(GetType(), new FakeCommandContext()
{
Client = client,
Guild = guild,
User = user,
Message = message,
Channel = messageChannel
});
}
public void Setup() =>
_logic = TestConfig.ExcuseGeneratorLogic();


[Test]
Expand Down
6 changes: 2 additions & 4 deletions Code2Gether-Discord-Bot.Tests/Fakes/FakeApplication.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using Discord;
using Discord;
using System;

namespace Code2Gether_Discord_Bot.Tests.Fakes
{
Expand Down
11 changes: 6 additions & 5 deletions Code2Gether-Discord-Bot.Tests/Fakes/FakeDiscordClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace Code2Gether_Discord_Bot.Tests.Fakes
{
internal class FakeDiscordClient : IDiscordClient
{
public IReadOnlyCollection<IGuild> Guilds { get; set; }
/*public IReadOnlyCollection<IGuild> Guilds { get; set; }

public IApplication FakeApplication { get; set; }
public IApplication FakeApplication { get; set; }*/

public ConnectionState ConnectionState { get; set; }

Expand All @@ -31,7 +30,8 @@ public void Dispose()

public Task<IApplication> GetApplicationInfoAsync(RequestOptions options = null)
{
return Task.FromResult(FakeApplication);
throw new NotImplementedException();
// return Task.FromResult(FakeApplication);
}

public Task<IChannel> GetChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null)
Expand Down Expand Up @@ -61,7 +61,8 @@ public Task<IGuild> GetGuildAsync(ulong id, CacheMode mode = CacheMode.AllowDown

public Task<IReadOnlyCollection<IGuild>> GetGuildsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null)
{
return Task.FromResult(Guilds);
throw new NotImplementedException();
// return Task.FromResult(Guilds);
}

public Task<IInvite> GetInviteAsync(string inviteId, RequestOptions options = null)
Expand Down
15 changes: 5 additions & 10 deletions Code2Gether-Discord-Bot.Tests/Fakes/FakeGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@
using Discord.Audio;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Globalization;
using System.Text;
using System.Threading.Tasks;

namespace Code2Gether_Discord_Bot.Tests.Fakes
{
internal class FakeGuild : IGuild
{
private Dictionary<ulong, IGuildChannel> _guildChannels = new Dictionary<ulong, IGuildChannel>()
{
{ 123456789123456789, new FakeGuildChannel() }
};

public string Name { get; set; }

public int AFKTimeout { get; set; }
Expand Down Expand Up @@ -188,16 +181,18 @@ public Task<IReadOnlyCollection<ICategoryChannel>> GetCategoriesAsync(CacheMode

public Task<IGuildChannel> GetChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null)
{
return Task.Run(() =>
throw new NotImplementedException();
/*return Task.Run(() =>
{
_guildChannels.TryGetValue(id, out IGuildChannel channel);
return channel;
});
});*/
}

public Task<IReadOnlyCollection<IGuildChannel>> GetChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null)
{
return Task.Run(() => (IReadOnlyCollection<IGuildChannel>)_guildChannels);
throw new NotImplementedException();
// return Task.Run(() => (IReadOnlyCollection<IGuildChannel>)_guildChannels);
}

public Task<IGuildUser> GetCurrentUserAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null)
Expand Down
19 changes: 9 additions & 10 deletions Code2Gether-Discord-Bot.Tests/Fakes/FakeGuildChannel.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
using System;
using Discord;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Discord;

namespace Code2Gether_Discord_Bot.Tests.Fakes
{
internal class FakeGuildChannel : IGuildChannel
{
public ulong Id { get; }
public DateTimeOffset CreatedAt { get; }
public IGuild Guild { get; }
public ulong GuildId { get; }
public ulong Id { get; }
public string Name { get; }
public IReadOnlyCollection<Overwrite> PermissionOverwrites { get; }
public int Position { get; }

public Task ModifyAsync(Action<GuildChannelProperties> func, RequestOptions options = null)
{
throw new NotImplementedException();
Expand Down Expand Up @@ -55,11 +60,6 @@ Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOpt
throw new NotImplementedException();
}

public int Position { get; }
public IGuild Guild { get; }
public ulong GuildId { get; }
public IReadOnlyCollection<Overwrite> PermissionOverwrites { get; }

IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
{
return GetUsersAsync(mode, options);
Expand All @@ -70,7 +70,6 @@ Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions optio
throw new NotImplementedException();
}

public string Name { get; }
public Task DeleteAsync(RequestOptions options = null)
{
throw new NotImplementedException();
Expand Down
21 changes: 21 additions & 0 deletions Code2Gether-Discord-Bot.Tests/Fakes/FakeLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Code2Gether_Discord_Bot.Library.Models;
using Discord;
using Discord.Commands;
using System;

namespace Code2Gether_Discord_Bot.Tests.Fakes
{
/// <summary>
/// Just a logger that logs nothing ¯\_(ツ)_/¯
/// </summary>
class FakeLogger : ILogger
{
public void Log(LogSeverity level, string message) { }

public void Log(LogSeverity level, Exception exception) { }

public void Log(LogSeverity level, string message, Exception exception) { }

public void Log(ICommandContext context) { }
}
}
1 change: 0 additions & 1 deletion Code2Gether-Discord-Bot.Tests/Fakes/FakeMessageChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace Code2Gether_Discord_Bot.Tests.Fakes
Expand Down
19 changes: 19 additions & 0 deletions Code2Gether-Discord-Bot.Tests/Fakes/FakeProject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Code2Gether_Discord_Bot.Library.Models;
using Discord;

namespace Code2Gether_Discord_Bot.Tests.Fakes
{
/// <summary>
/// Represents a fake <see cref="Project"/>.This class cannot be inherited.
/// </summary>
internal sealed class FakeProject : Project
{
/// <summary>
/// Initializes a new instance of the <see cref="FakeProject"/> class with the specified Id, Name and Author.
/// </summary>
/// <param name="id">This instance's Id.</param>
/// <param name="name">This intance's name.</param>
/// <param name="author">This instance's Author.</param>
public FakeProject(int id, string name, IUser author) : base(id, name, author) { }
}
}
Loading