@@ -15,52 +15,24 @@ public class SqlExceptionTest
15
15
private const string badServer = "92B96911A0BD43E8ADA4451031F7E7CF" ;
16
16
17
17
[ Fact ]
18
- [ ActiveIssue ( "12161" , TestPlatforms . AnyUnix ) ]
19
18
public void SerializationTest ( )
20
19
{
21
20
SqlException e = CreateException ( ) ;
22
21
string json = JsonConvert . SerializeObject ( e ) ;
23
22
24
- var settings = new JsonSerializerSettings ( )
25
- {
26
- TypeNameHandling = TypeNameHandling . All ,
27
- } ;
28
-
29
- // TODO: Deserialization fails on Unix with "Member 'ClassName' was not found."
23
+ var settings = new JsonSerializerSettings ( ) ;
30
24
var sqlEx = JsonConvert . DeserializeObject < SqlException > ( json , settings ) ;
31
25
32
26
Assert . Equal ( e . ClientConnectionId , sqlEx . ClientConnectionId ) ;
33
27
Assert . Equal ( e . StackTrace , sqlEx . StackTrace ) ;
34
28
}
35
29
36
- #if NETFRAMEWORK
37
- [ Fact ]
38
- [ ActiveIssue ( "12161" , TestPlatforms . AnyUnix ) ]
39
- public static void SqlExcpetionSerializationTest ( )
40
- {
41
- var formatter = new BinaryFormatter ( ) ;
42
- SqlException e = CreateException ( ) ;
43
- using ( var stream = new MemoryStream ( ) )
44
- {
45
- try
46
- {
47
- formatter . Serialize ( stream , e ) ;
48
- stream . Position = 0 ;
49
- var e2 = ( SqlException ) formatter . Deserialize ( stream ) ;
50
- }
51
- catch ( Exception ex )
52
- {
53
- Assert . Fail ( $ "Unexpected Exception occurred: { ex . Message } ") ;
54
- }
55
- }
56
- }
57
- #endif
58
-
59
30
[ Fact ]
60
31
public void JSONSerializationTest ( )
61
32
{
62
33
string clientConnectionId = "90cdab4d-2145-4c24-a354-c8ccff903542" ;
63
- string json = @"{""ClassName"":""Microsoft.Data.SqlClient.SqlException"","
34
+ string json = @"{"
35
+ + @"""ClassName"":""Microsoft.Data.SqlClient.SqlException"","
64
36
+ @"""Message"":""A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)"","
65
37
+ @"""Data"":{""HelpLink.ProdName"":""Microsoft SQL Server"","
66
38
+ @"""HelpLink.EvtSrc"":""MSSQLServer"","
@@ -79,13 +51,10 @@ public void JSONSerializationTest()
79
51
+ @"""Source"":""Core .Net SqlClient Data Provider"","
80
52
+ @"""WatsonBuckets"":null,"
81
53
+ @"""Errors"":null,"
82
- + @"""ClientConnectionId"":""90cdab4d-2145-4c24-a354-c8ccff903542""}" ;
83
-
84
- var settings = new JsonSerializerSettings ( )
85
- {
86
- TypeNameHandling = TypeNameHandling . All ,
87
- } ;
54
+ + @"""ClientConnectionId"":""90cdab4d-2145-4c24-a354-c8ccff903542"""
55
+ + @"}" ;
88
56
57
+ var settings = new JsonSerializerSettings ( ) ;
89
58
var sqlEx = JsonConvert . DeserializeObject < SqlException > ( json , settings ) ;
90
59
Assert . IsType < SqlException > ( sqlEx ) ;
91
60
Assert . Equal ( clientConnectionId , sqlEx . ClientConnectionId . ToString ( ) ) ;
0 commit comments