-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMoqGeneratorTests.cs
More file actions
75 lines (67 loc) · 2.76 KB
/
MoqGeneratorTests.cs
File metadata and controls
75 lines (67 loc) · 2.76 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Testura.Code.Models;
using Testura.Code.UnitTestGenerator.Generators.MockGenerators;
using Testura.Code.UnitTestGenerator.Tests.Helpers;
namespace Testura.Code.UnitTestGenerator.Tests.Generators.MockGenerators
{
[TestFixture]
public class MoqGeneratorTests
{
private MoqGenerator _moqGenerator;
[SetUp]
public void SetUp()
{
_moqGenerator = new MoqGenerator();
}
[Test]
public void CreateFields_WhenCreatingFieldsWithoutAnyMockTypes_ShouldOnlyContainTypeUnderTest()
{
var fields = _moqGenerator.GenerateFields(
typeof(MoqGeneratorTests),
new List<Parameter>());
Assert.AreEqual(1, fields.Count());
}
[Test]
public void CreateFields_WhenCreatingFieldsWithMockTypes_ShouldContainTypeUnderTestAndMockTypes()
{
var fields = _moqGenerator.GenerateFields(
typeof(MoqGeneratorTests),
new List<Parameter> { new Parameter("test", typeof(MoqGeneratorTests)) });
Assert.AreEqual(2, fields.Count());
}
[Test]
public void CreateFields_WhenCreatingFields_ShouldContainCorrectInformation()
{
var fields = _moqGenerator.GenerateFields(
typeof(MoqGeneratorTests),
new List<Parameter>());
Assert.AreEqual("privateMoqGeneratorTestsmoqGeneratorTests;", fields.First().ToString());
}
[Test]
public void CreateFields_WhenCreatingFieldsWithAbstractParameter_ShoulContainFieldAsMock()
{
var fields = _moqGenerator.GenerateFields(
typeof(MoqGeneratorTests),
new List<Parameter> { new Parameter("myMockClass", typeof(MyAbstractClass)) });
Assert.AreEqual("privateMock<MyAbstractClass>myMockClassMock;", fields.First().ToString());
}
[Test]
public void CreateFields_WhenCreatingFieldsWithArrayParameter_ShoulContainFieldAsArray()
{
var fields = _moqGenerator.GenerateFields(
typeof(MoqGeneratorTests),
new List<Parameter> { new Parameter("myArray", typeof(int[])) });
Assert.AreEqual("privateint[]myArray;", fields.First().ToString());
}
[Test]
public void CreateFields_WhenCreatingFieldsWithIListParameter_ShoulContainFieldAsIList()
{
var fields = _moqGenerator.GenerateFields(
typeof(MoqGeneratorTests),
new List<Parameter> { new Parameter("myList", typeof(IList<string>)) });
Assert.AreEqual("privateIList<string>myList;", fields.First().ToString());
}
}
}