Skip to content

Commit ad333a7

Browse files
Merge pull request #46 from nullinside-development-group/feature/SyncEditor
Fixing .editorconfig and formatting
2 parents ec4a6b4 + b9d3031 commit ad333a7

File tree

9 files changed

+523
-168
lines changed

9 files changed

+523
-168
lines changed

src/Nullinside.Api.TwitchBot.Tests/.editorconfig

Lines changed: 368 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,58 @@
11
using Moq;
2+
23
using Nullinside.Api.Common.Twitch;
34
using Nullinside.Api.Model.Ddl;
45
using Nullinside.Api.TwitchBot.ChatRules;
56

67
namespace Nullinside.Api.TwitchBot.Tests.ChatRules;
78

89
/// <summary>
9-
/// A generic set of sets that all chat rules should be put through.
10+
/// A generic set of sets that all chat rules should be put through.
1011
/// </summary>
1112
/// <typeparam name="T"></typeparam>
12-
public abstract class AChatRuleUnitTestBase<T> : UnitTestBase where T : AChatRule, new()
13-
{
14-
/// <summary>
15-
/// Tests that the message filter is capable of passing at all.
16-
/// </summary>
17-
/// <param name="goodString">A friendly string with no issues.</param>
18-
[Test]
19-
[TestCase("Hello I love candy and sprinkles")]
20-
public async Task TestItDoesntAlwaysFail(string goodString)
21-
{
22-
var rule = new T();
23-
var botProxy = new Mock<ITwitchApiProxy>();
24-
25-
// Process the message and assert that we pass the message.
26-
var chat = new TwitchChatMessage(true, goodString, "123", "456");
27-
var result = await rule.Handle("123", botProxy.Object, chat, _db);
28-
Assert.That(result, Is.True);
29-
30-
// Process the message and assert that we pass the message.
31-
chat = new TwitchChatMessage(false, goodString, "123", "456");
32-
result = await rule.Handle("123", botProxy.Object, chat, _db);
33-
Assert.That(result, Is.True);
34-
}
35-
36-
/// <summary>
37-
/// Tests that the rules are only running when they should be.
38-
/// </summary>
39-
[Test]
40-
public void TestShouldRun()
41-
{
42-
var rule = new T();
43-
44-
// Rule is turned on and so is scanning.
45-
var shouldRun = rule.ShouldRun(new TwitchUserConfig { Enabled = true, BanKnownBots = true });
46-
Assert.That(shouldRun, Is.True);
47-
48-
// Scanning is turned off
49-
shouldRun = rule.ShouldRun(new TwitchUserConfig { Enabled = false, BanKnownBots = true });
50-
Assert.That(shouldRun, Is.False);
51-
52-
// Rule is turned off.
53-
shouldRun = rule.ShouldRun(new TwitchUserConfig { Enabled = true, BanKnownBots = false });
54-
Assert.That(shouldRun, Is.False);
55-
56-
// Everything is off.
57-
shouldRun = rule.ShouldRun(new TwitchUserConfig { Enabled = false, BanKnownBots = false });
58-
Assert.That(shouldRun, Is.False);
59-
}
13+
public abstract class AChatRuleUnitTestBase<T> : UnitTestBase where T : AChatRule, new() {
14+
/// <summary>
15+
/// Tests that the message filter is capable of passing at all.
16+
/// </summary>
17+
/// <param name="goodString">A friendly string with no issues.</param>
18+
[Test]
19+
[TestCase("Hello I love candy and sprinkles")]
20+
public async Task TestItDoesntAlwaysFail(string goodString) {
21+
var rule = new T();
22+
var botProxy = new Mock<ITwitchApiProxy>();
23+
24+
// Process the message and assert that we pass the message.
25+
var chat = new TwitchChatMessage(true, goodString, "123", "456");
26+
bool result = await rule.Handle("123", botProxy.Object, chat, _db);
27+
Assert.That(result, Is.True);
28+
29+
// Process the message and assert that we pass the message.
30+
chat = new TwitchChatMessage(false, goodString, "123", "456");
31+
result = await rule.Handle("123", botProxy.Object, chat, _db);
32+
Assert.That(result, Is.True);
33+
}
34+
35+
/// <summary>
36+
/// Tests that the rules are only running when they should be.
37+
/// </summary>
38+
[Test]
39+
public void TestShouldRun() {
40+
var rule = new T();
41+
42+
// Rule is turned on and so is scanning.
43+
bool shouldRun = rule.ShouldRun(new TwitchUserConfig { Enabled = true, BanKnownBots = true });
44+
Assert.That(shouldRun, Is.True);
45+
46+
// Scanning is turned off
47+
shouldRun = rule.ShouldRun(new TwitchUserConfig { Enabled = false, BanKnownBots = true });
48+
Assert.That(shouldRun, Is.False);
49+
50+
// Rule is turned off.
51+
shouldRun = rule.ShouldRun(new TwitchUserConfig { Enabled = true, BanKnownBots = false });
52+
Assert.That(shouldRun, Is.False);
53+
54+
// Everything is off.
55+
shouldRun = rule.ShouldRun(new TwitchUserConfig { Enabled = false, BanKnownBots = false });
56+
Assert.That(shouldRun, Is.False);
57+
}
6058
}
Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
11
using Moq;
2+
23
using Nullinside.Api.Common.Twitch;
34
using Nullinside.Api.TwitchBot.ChatRules;
45

56
namespace Nullinside.Api.TwitchBot.Tests.ChatRules;
67

78
/// <summary>
8-
/// Tests the <see cref="BestCheapViewers" /> class.
9+
/// Tests the <see cref="BestCheapViewers" /> class.
910
/// </summary>
10-
public class BestCheapViewersTests : AChatRuleUnitTestBase<BestCheapViewers>
11-
{
12-
/// <summary>
13-
/// Tests strings that have been typed in chats.
14-
/// </summary>
15-
/// <param name="badString">The string that should fail.</param>
16-
[Test]
17-
[TestCase("Best viewers on ***")]
18-
[TestCase("Best viewers on ***")]
19-
[TestCase("Best vie̮wers on ***")]
20-
[TestCase("Best́ viewers on ***")]
21-
[TestCase("Be̩st Viewers on ***")]
22-
[TestCase("Be̾st Viewers on ***")]
23-
[TestCase("B͟est Viewers on ***")]
24-
[TestCase("B̟est viewers on ***")]
25-
[TestCase("Cheap viewers on ***")]
26-
[TestCase("Che̢ap vie̮wers on ***")]
27-
[TestCase("Ch̍eap Viewers on ***")]
28-
[TestCase("Ch͟eap viewers on ***")]
29-
[TestCase("C̀heap Viewers on ***")]
30-
[TestCase("Cheaͧp v̫iewers on ***")]
31-
[TestCase("Cheaͧp v̫iewers on *** ")]
32-
public async Task TestKnownStrings(string badString)
33-
{
34-
var rule = new BestCheapViewers();
35-
var botProxy = new Mock<ITwitchApiProxy>();
36-
var chat = new TwitchChatMessage(true, badString, "123", "456");
11+
public class BestCheapViewersTests : AChatRuleUnitTestBase<BestCheapViewers> {
12+
/// <summary>
13+
/// Tests strings that have been typed in chats.
14+
/// </summary>
15+
/// <param name="badString">The string that should fail.</param>
16+
[Test]
17+
[TestCase("Best viewers on ***")]
18+
[TestCase("Best viewers on ***")]
19+
[TestCase("Best vie̮wers on ***")]
20+
[TestCase("Best́ viewers on ***")]
21+
[TestCase("Be̩st Viewers on ***")]
22+
[TestCase("Be̾st Viewers on ***")]
23+
[TestCase("B͟est Viewers on ***")]
24+
[TestCase("B̟est viewers on ***")]
25+
[TestCase("Cheap viewers on ***")]
26+
[TestCase("Che̢ap vie̮wers on ***")]
27+
[TestCase("Ch̍eap Viewers on ***")]
28+
[TestCase("Ch͟eap viewers on ***")]
29+
[TestCase("C̀heap Viewers on ***")]
30+
[TestCase("Cheaͧp v̫iewers on ***")]
31+
[TestCase("Cheaͧp v̫iewers on *** ")]
32+
public async Task TestKnownStrings(string badString) {
33+
var rule = new BestCheapViewers();
34+
var botProxy = new Mock<ITwitchApiProxy>();
35+
var chat = new TwitchChatMessage(true, badString, "123", "456");
3736

38-
// Process the message and assert that we fail the message.
39-
var result = await rule.Handle("123", botProxy.Object, chat, _db);
40-
Assert.That(result, Is.False);
41-
}
37+
// Process the message and assert that we fail the message.
38+
bool result = await rule.Handle("123", botProxy.Object, chat, _db);
39+
Assert.That(result, Is.False);
40+
}
4241
}
Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,48 @@
11
using Moq;
2+
23
using Nullinside.Api.Common.Twitch;
34
using Nullinside.Api.TwitchBot.ChatRules;
45

56
namespace Nullinside.Api.TwitchBot.Tests.ChatRules;
67

78
/// <summary>
8-
/// Tests the <see cref="Discord" /> class.
9+
/// Tests the <see cref="Discord" /> class.
910
/// </summary>
10-
public class DiscordTests : AChatRuleUnitTestBase<Discord>
11-
{
12-
/// <summary>
13-
/// Tests the strings typed in chats.
14-
/// </summary>
15-
/// <param name="badString">The string that should fail.</param>
16-
[Test]
17-
[TestCase(
18-
"Hello mate you stream pretty cool that's why I follow I would love to be a fan of yours if you don't mind kindly add me on Discord: 👉👉lacaster5")]
19-
[TestCase(
20-
"Hello, I just recently found your channel and can already tell that your content is great, and I would love to stick with you long term. If you're open to it, I'd be willing to connect with you on Discord. My username is teecash1000")]
21-
[TestCase(
22-
"Hey there 👋 You stream pretty cool that’s why I followed you. I will like to make you a friend and be a fan, if you don’t mind Kindly chat me on Discord, my Discord username is tuckzay")]
23-
[TestCase(
24-
"Hi! Just wanted to say that I absolutely love your gameplay and content.l'd love to connect better with you on Discord if that's possible. Looking forward to more awesome streams from you! My username is 👉👉👉 edisonpires")]
25-
[TestCase(
26-
"What's up Friend, great stream! I'm having a blast watching you stream. Let's move the conversation to Discord, where we can discuss more about streaming in more detail and get to know each other better. See you there! My discord username is 👉john_6029")]
27-
public async Task TestKnownStrings(string badString)
28-
{
29-
var rule = new Discord();
30-
var botProxy = new Mock<ITwitchApiProxy>();
31-
var chat = new TwitchChatMessage(true, badString, "123", "456");
11+
public class DiscordTests : AChatRuleUnitTestBase<Discord> {
12+
/// <summary>
13+
/// Tests the strings typed in chats.
14+
/// </summary>
15+
/// <param name="badString">The string that should fail.</param>
16+
[Test]
17+
[TestCase("Hello mate you stream pretty cool that's why I follow I would love to be a fan of yours if you don't mind kindly add me on Discord: 👉👉lacaster5")]
18+
[TestCase("Hello, I just recently found your channel and can already tell that your content is great, and I would love to stick with you long term. If you're open to it, I'd be willing to connect with you on Discord. My username is teecash1000")]
19+
[TestCase("Hey there 👋 You stream pretty cool that’s why I followed you. I will like to make you a friend and be a fan, if you don’t mind Kindly chat me on Discord, my Discord username is tuckzay")]
20+
[TestCase("Hi! Just wanted to say that I absolutely love your gameplay and content.l'd love to connect better with you on Discord if that's possible. Looking forward to more awesome streams from you! My username is 👉👉👉 edisonpires")]
21+
[TestCase("What's up Friend, great stream! I'm having a blast watching you stream. Let's move the conversation to Discord, where we can discuss more about streaming in more detail and get to know each other better. See you there! My discord username is 👉john_6029")]
22+
public async Task TestKnownStrings(string badString) {
23+
var rule = new Discord();
24+
var botProxy = new Mock<ITwitchApiProxy>();
25+
var chat = new TwitchChatMessage(true, badString, "123", "456");
3226

33-
// Process the message and assert that we fail the message.
34-
var result = await rule.Handle("123", botProxy.Object, chat, _db);
35-
Assert.That(result, Is.False);
36-
}
27+
// Process the message and assert that we fail the message.
28+
bool result = await rule.Handle("123", botProxy.Object, chat, _db);
29+
Assert.That(result, Is.False);
30+
}
3731

38-
/// <summary>
39-
/// Ensure that the rule doesn't fail just because it contains the word discord.
40-
/// </summary>
41-
/// <param name="message">The message.</param>
42-
[Test]
43-
[TestCase("I've heard of the application discord before and it sounds great")]
44-
[TestCase("I was talking on my discord the other day")]
45-
public async Task EnsureNoFalsePositives(string message)
46-
{
47-
var rule = new Discord();
48-
var botProxy = new Mock<ITwitchApiProxy>();
49-
var chat = new TwitchChatMessage(true, message, "123", "456");
32+
/// <summary>
33+
/// Ensure that the rule doesn't fail just because it contains the word discord.
34+
/// </summary>
35+
/// <param name="message">The message.</param>
36+
[Test]
37+
[TestCase("I've heard of the application discord before and it sounds great")]
38+
[TestCase("I was talking on my discord the other day")]
39+
public async Task EnsureNoFalsePositives(string message) {
40+
var rule = new Discord();
41+
var botProxy = new Mock<ITwitchApiProxy>();
42+
var chat = new TwitchChatMessage(true, message, "123", "456");
5043

51-
// Process the message and assert that we do not fail the message.
52-
var result = await rule.Handle("123", botProxy.Object, chat, _db);
53-
Assert.That(result, Is.True);
54-
}
44+
// Process the message and assert that we do not fail the message.
45+
bool result = await rule.Handle("123", botProxy.Object, chat, _db);
46+
Assert.That(result, Is.True);
47+
}
5548
}
Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
11
using Moq;
2+
23
using Nullinside.Api.Common.Twitch;
34
using Nullinside.Api.TwitchBot.ChatRules;
45

56
namespace Nullinside.Api.TwitchBot.Tests.ChatRules;
67

78
/// <summary>
8-
/// Tests the <see cref="StreamViewers" /> class.
9+
/// Tests the <see cref="StreamViewers" /> class.
910
/// </summary>
10-
public class StreamViewersTests : AChatRuleUnitTestBase<StreamViewers>
11-
{
12-
/// <summary>
13-
/// Tests the strings typed in chats.
14-
/// </summary>
15-
/// <param name="badString">The string that should fail.</param>
16-
[Test]
17-
[TestCase(
18-
"@jellynyeko dо уоu alrеady triеd strеamviewers оrg? Real viewеrs, fire works! Тhеy arе now giving оut а frее рackagе for streamers оО")]
19-
[TestCase(
20-
"@kygaming98 dо уоu аlready tried streаmviewers оrg? Real viewers, firе works! Thеy arе now giving оut а freе package fоr streamers oО")]
21-
public async Task TestKnownStrings(string badString)
22-
{
23-
var rule = new StreamViewers();
24-
var botProxy = new Mock<ITwitchApiProxy>();
25-
var chat = new TwitchChatMessage(true, badString, "123", "456");
11+
public class StreamViewersTests : AChatRuleUnitTestBase<StreamViewers> {
12+
/// <summary>
13+
/// Tests the strings typed in chats.
14+
/// </summary>
15+
/// <param name="badString">The string that should fail.</param>
16+
[Test]
17+
[TestCase("@jellynyeko dо уоu alrеady triеd strеamviewers оrg? Real viewеrs, fire works! Тhеy arе now giving оut а frее рackagе for streamers оО")]
18+
[TestCase("@kygaming98 dо уоu аlready tried streаmviewers оrg? Real viewers, firе works! Thеy arе now giving оut а freе package fоr streamers oО")]
19+
public async Task TestKnownStrings(string badString) {
20+
var rule = new StreamViewers();
21+
var botProxy = new Mock<ITwitchApiProxy>();
22+
var chat = new TwitchChatMessage(true, badString, "123", "456");
2623

27-
// Process the message and assert that we fail the message.
28-
var result = await rule.Handle("123", botProxy.Object, chat, _db);
29-
Assert.That(result, Is.False);
30-
}
24+
// Process the message and assert that we fail the message.
25+
bool result = await rule.Handle("123", botProxy.Object, chat, _db);
26+
Assert.That(result, Is.False);
27+
}
3128
}

src/Nullinside.Api.TwitchBot.Tests/Nullinside.Api.TwitchBot.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@
3232
<ItemGroup>
3333
<ProjectReference Include="..\Nullinside.Api.TwitchBot\Nullinside.Api.TwitchBot.csproj"/>
3434
</ItemGroup>
35-
3635
</Project>
Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11
using Microsoft.EntityFrameworkCore;
22
using Microsoft.EntityFrameworkCore.Diagnostics;
3+
34
using Nullinside.Api.Model;
45

56
namespace Nullinside.Api.TwitchBot.Tests;
67

78
/// <summary>
8-
/// A base class for all unit tests.
9+
/// A base class for all unit tests.
910
/// </summary>
10-
public abstract class UnitTestBase
11-
{
11+
public abstract class UnitTestBase {
1212
/// <summary>
13-
/// A fake database.
13+
/// A fake database.
1414
/// </summary>
1515
protected INullinsideContext _db;
1616

17-
[SetUp]
18-
public virtual void Setup()
19-
{
20-
// Create an in-memory database to fake the SQL queries. Note that we generate a random GUID for the name
21-
// here. If you use the same name more than once you'll get collisions between tests.
22-
var contextOptions = new DbContextOptionsBuilder<NullinsideContext>()
23-
.UseInMemoryDatabase(Guid.NewGuid().ToString())
24-
.ConfigureWarnings(b => b.Ignore(InMemoryEventId.TransactionIgnoredWarning))
25-
.Options;
26-
_db = new NullinsideContext(contextOptions);
27-
}
17+
[SetUp]
18+
public virtual void Setup() {
19+
// Create an in-memory database to fake the SQL queries. Note that we generate a random GUID for the name
20+
// here. If you use the same name more than once you'll get collisions between tests.
21+
DbContextOptions<NullinsideContext> contextOptions = new DbContextOptionsBuilder<NullinsideContext>()
22+
.UseInMemoryDatabase(Guid.NewGuid().ToString())
23+
.ConfigureWarnings(b => b.Ignore(InMemoryEventId.TransactionIgnoredWarning))
24+
.Options;
25+
_db = new NullinsideContext(contextOptions);
26+
}
2827

29-
[TearDown]
30-
public virtual async Task TearDown()
31-
{
32-
// Dispose since it has one.
33-
await _db.DisposeAsync();
34-
}
28+
[TearDown]
29+
public virtual async Task TearDown() {
30+
// Dispose since it has one.
31+
await _db.DisposeAsync();
32+
}
3533
}

src/Nullinside.Api.TwitchBot/.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ root = true
44
[*]
55
indent_style = space
66

7+
# ReSharper properties
8+
resharper_csharp_wrap_lines = false
9+
710
# Xml files
811
[*.xml]
912
indent_size = 2

0 commit comments

Comments
 (0)