/
MultipleParameters.cs
72 lines (58 loc) · 1.67 KB
/
MultipleParameters.cs
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
namespace Examples;
using System;
using FluentAssertions;
using NSubstitute;
using Xunit;
public interface IFirstService
{
int GetValue();
}
public interface ISecondService
{
int GetValue();
}
public interface IThirdService
{
int GetValue();
}
public interface IFourthService
{
string GetMessage(int value);
}
public class MultipleParameters
{
private readonly IFirstService _firstService;
private readonly IFourthService _fourthService;
private readonly ISecondService _secondService;
private readonly IThirdService _thirdService;
public MultipleParameters(IFirstService firstService, ISecondService secondService, IThirdService thirdService,
IFourthService fourthService)
{
_firstService = firstService;
_secondService = secondService;
_thirdService = thirdService;
_fourthService = fourthService;
}
public string BuildMessage()
{
var firstValue = _firstService.GetValue();
var secondValue = _secondService.GetValue();
var thirdValue = _thirdService.GetValue();
var total = firstValue + secondValue + thirdValue;
return _fourthService.GetMessage(total);
}
}
public class MultipleParametersTest : Tests<MultipleParameters>
{
[Fact]
public void CanSupportMultipleServices()
{
var expected = Guid.NewGuid().ToString();
Service<IFirstService>().GetValue().Returns(3);
Service<ISecondService>().GetValue().Returns(8);
Service<IThirdService>().GetValue().Returns(43);
Service<IFourthService>().GetMessage(54).Returns(expected);
var actual = SUT.BuildMessage();
actual.Should().Be(expected);
}
}