Skip to content

Commit 72d42aa

Browse files
Sergio FerreiraSergio Ferreira
Sergio Ferreira
authored and
Sergio Ferreira
committed
creating problematic unit-tests
1 parent 53a97e4 commit 72d42aa

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28010.2016
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestMyStuff", "TestMyStuff\TestMyStuff.csproj", "{4D3DCF25-EBD5-457C-9320-86F4C0190648}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{4D3DCF25-EBD5-457C-9320-86F4C0190648}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4D3DCF25-EBD5-457C-9320-86F4C0190648}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4D3DCF25-EBD5-457C-9320-86F4C0190648}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4D3DCF25-EBD5-457C-9320-86F4C0190648}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {5BEC1317-CC17-43B9-9382-8024F80E31D0}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using System;
2+
using Xunit;
3+
4+
namespace TestMyStuff
5+
{
6+
public class BigBadTests
7+
{
8+
[Fact]
9+
public void Test1()
10+
{
11+
var subject = new SubjectUnderTest();
12+
13+
var result = subject.SomeCalculation();
14+
15+
Assert.NotNull(result);
16+
Assert.NotNull(result.Field);
17+
}
18+
19+
[Fact]
20+
public void Test2()
21+
{
22+
var subject = new SubjectUnderTest();
23+
24+
try
25+
{
26+
subject.ThrowException();
27+
Assert.False(true);
28+
}
29+
catch (Exception e)
30+
{
31+
Console.WriteLine(e);
32+
}
33+
}
34+
35+
[Fact]
36+
public void Test3()
37+
{
38+
var subject1 = new SubjectUnderTest();
39+
var subject2 = new SubjectUnderTest();
40+
41+
var result = subject1.SomeCalculation();
42+
43+
if (result != null)
44+
{
45+
var result2 = subject2.SomeCalculation();
46+
Assert.NotNull(result2);
47+
Assert.NotEqual(result2, result);
48+
}
49+
else
50+
{
51+
var result2 = subject2.SomeCalculation();
52+
Assert.NotNull(result2);
53+
}
54+
}
55+
56+
}
57+
58+
public class SubjectUnderTest
59+
{
60+
public ComplexObject SomeCalculation()
61+
{
62+
return new ComplexObject
63+
{
64+
Field = new SomeOtherObject()
65+
};
66+
}
67+
68+
public void ThrowException()
69+
{
70+
throw new Exception();
71+
}
72+
}
73+
74+
public class SomeOtherObject { }
75+
76+
public class ComplexObject
77+
{
78+
public SomeOtherObject Field { get; set; }
79+
}
80+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
11+
<PackageReference Include="xunit" Version="2.3.1" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
13+
</ItemGroup>
14+
15+
</Project>

0 commit comments

Comments
 (0)