Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit add2959

Browse files
committed
Clean up .NET Core code on tests
1 parent f3d0a40 commit add2959

File tree

7 files changed

+27
-45
lines changed

7 files changed

+27
-45
lines changed

tests/ServiceStack.Text.Tests/AttributeTests.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public void Does_get_Multiple_RouteDefault_Attributes()
3838
// AllAttributes<T>() makes this call to get attrs
3939
#if NETCORE
4040
var referenceGeneric =
41-
typeof(DefaultWithMultipleAttributes).GetTypeInfo().GetCustomAttributes(true)
42-
.Where(x => x.GetType().IsInstanceOf(typeof(RouteDefaultAttribute)))
41+
typeof(DefaultWithMultipleAttributes).GetTypeInfo().GetCustomAttributes(typeof(RouteDefaultAttribute), true)
4342
.OfType<RouteDefaultAttribute>();
4443
#else
4544
var referenceGeneric =
@@ -52,8 +51,7 @@ public void Does_get_Multiple_RouteDefault_Attributes()
5251
// AllAttributes() makes this call to get attrs
5352
#if NETCORE
5453
var reference =
55-
typeof(DefaultWithMultipleAttributes).GetTypeInfo().GetCustomAttributes(true)
56-
.Where(x => x.GetType().IsInstanceOf(typeof(RouteDefaultAttribute))).ToArray();
54+
typeof(DefaultWithMultipleAttributes).GetTypeInfo().GetCustomAttributes(typeof(RouteDefaultAttribute), true);
5755
#else
5856
var reference =
5957
typeof(DefaultWithMultipleAttributes).GetCustomAttributes(typeof(RouteDefaultAttribute), true);
@@ -257,11 +255,11 @@ public RouteTypeIdAttribute(string path, string verbs)
257255
public string Path { get; set; }
258256
public string Verbs { get; set; }
259257

258+
public
260259
#if !NETCORE
261-
public override object TypeId
262-
#else
263-
public object TypeId
260+
override
264261
#endif
262+
object TypeId
265263
{
266264
get
267265
{

tests/ServiceStack.Text.Tests/BclStructTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public class ExampleType
6060
public int Foo { get; set; }
6161
}
6262

63-
#if !NETCORE
6463
[Test]
6564
public void Can_serialize_dto_with_enum_flags()
6665
{
@@ -78,7 +77,6 @@ public void Can_serialize_dto_with_enum_flags()
7877

7978
Assert.That(deserialized.Enum, Is.EqualTo(ExampleEnum.One | ExampleEnum.Four));
8079
}
81-
#endif
8280

8381
[DataContract]
8482
public class Item

tests/ServiceStack.Text.Tests/InterfaceTests.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ public void Can_serialize_IMessage()
2929
var message = new Message<string> { Id = new Guid(), CreatedDate = new DateTime(), Body = "test" };
3030
var messageString = TypeSerializer.SerializeToString((IMessage<string>)message);
3131

32-
#if NETCORE
33-
var assembly = "System.Private.CoreLib";
34-
#else
35-
var assembly = "mscorlib";
36-
#endif
32+
var assembly = typeof(string).GetAssembly().GetName().Name;
3733

3834
Assert.That(messageString, Is.EqualTo(
3935
"{__type:\"ServiceStack.Messaging.Message`1[[System.String, " + assembly + "]], ServiceStack.Interfaces\","
@@ -80,11 +76,7 @@ public static IEnumerable EndpointExpectations
8076
{
8177
get
8278
{
83-
#if NETCORE
84-
var assembly = "System.Private.CoreLib";
85-
#else
86-
var assembly = "mscorlib";
87-
#endif
79+
var assembly = typeof(string).GetAssembly().GetName().Name;
8880

8981
yield return new TestCaseData(typeof(Message<string>),
9082
"ServiceStack.Messaging.Message`1[[System.String, " + assembly + "]], ServiceStack.Interfaces");

tests/ServiceStack.Text.Tests/JsonTests/PolymorphicListTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,7 @@ public void SetUp()
120120
{
121121
JsConfig.Reset();
122122
JsConfig<ICat>.ExcludeTypeInfo = false;
123-
#if NETCORE
124-
assemblyName = GetType().GetTypeInfo().Assembly.GetName().Name;
125-
#else
126-
assemblyName = GetType().Assembly.GetName().Name;
127-
#endif
123+
assemblyName = GetType().GetAssembly().GetName().Name;
128124
}
129125

130126
[Test]

tests/ServiceStack.Text.Tests/TypeConverterTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#if !NETCORE
21
using System;
32
using System.ComponentModel;
4-
using System.Security.Policy;
53
using NUnit.Framework;
4+
#if !NETCORE
5+
using System.Security.Policy;
6+
#endif
67

78
namespace ServiceStack.Text.Tests
89
{
@@ -23,8 +24,10 @@ public CustomException(string message) : base(message)
2324
[Test]
2425
public void View_TypeConverter_outputs()
2526
{
27+
#if !NETCORE
2628
var converter1 = TypeDescriptor.GetConverter(typeof(Url));
2729
Console.WriteLine(converter1.ConvertToString(new Url("http://io/")));
30+
#endif
2831

2932
var converter2 = TypeDescriptor.GetConverter(typeof(Type));
3033
Console.WriteLine(converter2.ConvertToString(typeof(TypeConverterTests)));
@@ -36,5 +39,4 @@ public void View_TypeConverter_outputs()
3639
//Console.WriteLine(value3.Dump());
3740
}
3841
}
39-
}
40-
#endif
42+
}

tests/ServiceStack.Text.Tests/Utils/DateTimeSerializerTests.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@ public class DateTimeSerializerTests
1212
{
1313
public void PrintFormats(DateTime dateTime)
1414
{
15-
#if NETCORE
1615
Log("dateTime.ToShortDateString(): " + dateTime.ToString("d"));
1716
Log("dateTime.ToLongDateString(): " + dateTime.ToString("D"));
1817
Log("dateTime.ToShortTimeString(): " + dateTime.ToString("t"));
1918
Log("dateTime.ToLongTimeString(): " + dateTime.ToString("T"));
20-
#else
21-
Log("dateTime.ToShortDateString(): " + dateTime.ToShortDateString());
22-
Log("dateTime.ToLongDateString(): " + dateTime.ToLongDateString());
23-
Log("dateTime.ToShortTimeString(): " + dateTime.ToShortTimeString());
24-
Log("dateTime.ToLongTimeString(): " + dateTime.ToLongTimeString());
25-
#endif
19+
2620
Log("dateTime.ToString(): " + dateTime.ToString());
2721
Log("DateTimeSerializer.ToShortestXsdDateTimeString(dateTime): " + DateTimeSerializer.ToShortestXsdDateTimeString(dateTime));
2822
Log("DateTimeSerializer.ToDateTimeString(dateTime): " + DateTimeSerializer.ToDateTimeString(dateTime));

tests/ServiceStack.Text.Tests/project.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,20 @@
2626
"Northwind.Common" : "1.*",
2727
"ServiceStack.Text" : "1.0.*",
2828
"ServiceStack.Common" : "1.0.*",
29-
"ServiceStack.Client" : "1.0.*",
29+
"ServiceStack.Client" : "1.0.*"
3030
},
3131
"frameworks": {
3232
"netcoreapp1.0": {
33-
"imports": "dnxcore50",
34-
"dependencies" : {
35-
"System.Drawing.Primitives" : "4.0.0",
36-
"System.Collections.Specialized": "4.0.1",
37-
"System.Runtime.Serialization.Json": "4.0.2",
38-
"System.Collections.NonGeneric": "4.0.1",
39-
"System.Diagnostics.TraceSource": "4.0.0"
40-
}
41-
}
33+
"imports": "dnxcore50",
34+
"dependencies" : {
35+
"System.Drawing.Primitives" : "4.0.0",
36+
"System.Collections.Specialized": "4.0.1",
37+
"System.Runtime.Serialization.Json": "4.0.2",
38+
"System.Collections.NonGeneric": "4.0.1",
39+
"System.Diagnostics.TraceSource": "4.0.0",
40+
"System.Reflection.Extensions": "4.0.1",
41+
"System.ComponentModel.TypeConverter": "4.1.0"
42+
}
43+
}
4244
}
4345
}

0 commit comments

Comments
 (0)