Skip to content

Commit d0748aa

Browse files
authored
Merge pull request #230 from mwhelan/netcore
Netcore
2 parents 7f4a755 + 5b1688f commit d0748aa

File tree

11 files changed

+62
-76
lines changed

11 files changed

+62
-76
lines changed

src/TestStack.BDDfy.Tests/Reporters/Diagnostics/DiagnosticsReportBuilderTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if NSubstitute
2-
using NSubstitute;
1+
using NSubstitute;
32
using TestStack.BDDfy.Reporters;
43
using TestStack.BDDfy.Reporters.Diagnostics;
54
using TestStack.BDDfy.Reporters.Serializers;
@@ -22,5 +21,4 @@ public void ShouldSerializeDiagnosticDataToSpecifiedFormat()
2221
serializer.Received().Serialize(Arg.Any<object>());
2322
}
2423
}
25-
}
26-
#endif
24+
}

src/TestStack.BDDfy.Tests/Reporters/Diagnostics/DiagnosticsReporterTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if NSubstitute
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using NSubstitute;
54
using TestStack.BDDfy.Reporters;
@@ -46,5 +45,4 @@ private DiagnosticsReporter CreateSut()
4645
return new DiagnosticsReporter(_builder, _writer);
4746
}
4847
}
49-
}
50-
#endif
48+
}

src/TestStack.BDDfy.Tests/Reporters/Html/HtmlReporterTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if NSubstitute
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using NSubstitute;
54
using Shouldly;
@@ -99,5 +98,4 @@ public void ShouldNotLoadCustomJavascriptIfNoneExist()
9998
_sut.FileReader.DidNotReceive().Read(customJavascript);
10099
}
101100
}
102-
}
103-
#endif
101+
}

src/TestStack.BDDfy.Tests/Reporters/Html/TestableHtmlReporter.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if NSubstitute
21
using NSubstitute;
32
using TestStack.BDDfy.Reporters;
43
using TestStack.BDDfy.Reporters.Html;
@@ -30,5 +29,4 @@ public static TestableHtmlReporter Create()
3029
Substitute.For<IReportWriter>(), Substitute.For<IFileReader>());
3130
}
3231
}
33-
}
34-
#endif
32+
}

src/TestStack.BDDfy.Tests/Reporters/MarkDown/MarkDownReporterTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if NSubstitute
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using NSubstitute;
54
using TestStack.BDDfy.Reporters;
@@ -46,5 +45,4 @@ private MarkDownReporter CreateSut()
4645
return new MarkDownReporter(_builder, _writer);
4746
}
4847
}
49-
}
50-
#endif
48+
}

src/TestStack.BDDfy.Tests/Scanner/FluentScanner/DoesNotConflictWithnSubstitute.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if NSubstitute
2-
using NSubstitute;
1+
using NSubstitute;
32
using Xunit;
43

54
namespace TestStack.BDDfy.Tests.Scanner.FluentScanner
@@ -34,5 +33,4 @@ private void GivenSomeStuff()
3433
_subsitute = Substitute.For<ITestContext>();
3534
}
3635
}
37-
}
38-
#endif
36+
}

src/TestStack.BDDfy.Tests/project.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
2-
"dependencies": {
3-
"Shouldly": "2.8.0",
4-
"TestStack.BDDfy": {
5-
"target": "project"
6-
},
7-
"Microsoft.NETCore.Platforms": "1.0.1",
8-
"xunit.core": "2.2.0-beta2-build3300",
9-
"dotnet-test-xunit": "2.2.0-preview2-build1029"
2+
"dependencies": {
3+
"Shouldly": "2.8.0",
4+
"TestStack.BDDfy": {
5+
"target": "project"
106
},
7+
"Microsoft.NETCore.Platforms": "1.0.1",
8+
"NSubstitute": "2.0.0-alpha003",
9+
"System.Diagnostics.TraceSource": "4.0.0",
10+
"xunit.core": "2.2.0-beta2-build3300",
11+
"dotnet-test-xunit": "2.2.0-preview2-build1029"
12+
},
1113
"frameworks": {
1214
"netcoreapp1.0": {
1315
"dependencies": {
@@ -23,14 +25,12 @@
2325
]
2426
},
2527
"net46": {
26-
"dependencies": {
27-
"NSubstitute": "1.10.0"
28-
},
28+
"dependencies": {
29+
},
2930
"buildOptions": {
3031
"define": [
3132
"Approvals",
32-
"Culture",
33-
"NSubstitute"
33+
"Culture"
3434
]
3535
}
3636
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.Collections.Generic;
2+
3+
namespace TestStack.BDDfy.Reporters.Diagnostics
4+
{
5+
public class DiagnosticsReport
6+
{
7+
public IList<StoryDiagnostic> Stories { get; set; }
8+
}
9+
}

src/TestStack.BDDfy/Reporters/Diagnostics/DiagnosticsReportBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public DiagnosticsReportBuilder(ISerializer serializer)
1818
public string CreateReport(FileReportModel model)
1919
{
2020
var graph = GetDiagnosticData(model);
21-
var rootObject = new { Stories = graph };
21+
var rootObject = new DiagnosticsReport { Stories = graph };
2222
return _serializer.Serialize(rootObject);
2323
}
2424

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,22 @@
1+
using System.IO;
2+
using System.Runtime.Serialization.Json;
3+
using System.Text;
4+
15
namespace TestStack.BDDfy.Reporters.Serializers
26
{
3-
#if NET40
4-
using System.Web.Script.Serialization;
5-
67
public class JsonSerializer : ISerializer
78
{
89
public string Serialize(object obj)
910
{
10-
var serializer = new JavaScriptSerializer();
11-
string json = serializer.Serialize(obj);
11+
var serializer = new DataContractJsonSerializer(obj.GetType());
12+
string json;
13+
using (var stream = new MemoryStream())
14+
{
15+
serializer.WriteObject(stream, obj);
16+
json = Encoding.UTF8.GetString(stream.ToArray());
17+
}
1218

1319
return new JsonFormatter(json).Format();
1420
}
1521
}
16-
17-
#else
18-
using Newtonsoft.Json;
19-
20-
public class JsonSerializer : ISerializer
21-
{
22-
public string Serialize(object obj)
23-
{
24-
return JsonConvert.SerializeObject(obj, Formatting.Indented,
25-
new JsonSerializerSettings
26-
{
27-
NullValueHandling = NullValueHandling.Ignore,
28-
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
29-
});
30-
}
31-
}
32-
33-
#endif
34-
3522
}

0 commit comments

Comments
 (0)