-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathAddCurrencyToShould.cs
More file actions
48 lines (41 loc) · 1.75 KB
/
AddCurrencyToShould.cs
File metadata and controls
48 lines (41 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using DevChatter.Bot.Core;
using DevChatter.Bot.Core.Data;
using DevChatter.Bot.Core.Data.Model;
using DevChatter.Bot.Core.Data.Specifications;
using DevChatter.Bot.Core.Events;
using DevChatter.Bot.Core.Systems.Chat;
using FluentAssertions;
using Moq;
using Xunit;
namespace UnitTests.Core.Events.CurrencyGeneratorTests
{
public class AddCurrencyToShould
{
[Fact]
public void AllowGoingToMaxInt_GivenZeroStartAndMaxIntAdded()
{
var mockRepo = new Mock<IRepository>();
var mockKnownBot = new Mock<IKnownBotService>();
var currencyGenerator = new CurrencyGenerator(new List<IChatClient>(),
new ChatUserCollection(mockRepo.Object, mockKnownBot.Object));
var chatUser = new ChatUser {Tokens = 0};
mockRepo.Setup(x => x.List(It.IsAny<ChatUserPolicy>())).Returns(new List<ChatUser> { chatUser });
currencyGenerator.AddCurrencyTo("twitchloff", int.MaxValue);
chatUser.Tokens.Should().Be(int.MaxValue);
}
[Fact]
public void CapAtMaxInt_GivenOverflowPossibility()
{
var mockRepo = new Mock<IRepository>();
var mockKnownBot = new Mock<IKnownBotService>();
var currencyGenerator = new CurrencyGenerator(new List<IChatClient>(),
new ChatUserCollection(mockRepo.Object, mockKnownBot.Object));
var chatUser = new ChatUser {Tokens = 100};
mockRepo.Setup(x => x.List(It.IsAny<ChatUserPolicy>())).Returns(new List<ChatUser> { chatUser });
Action testCode = () => currencyGenerator.AddCurrencyTo("twitchloff", int.MaxValue);
testCode.Should().Throw<OverflowException>();
}
}
}