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

Commit cf8f57e

Browse files
committed
Add ResponseStatusErrorTests
1 parent a11d50d commit cf8f57e

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Globalization;
2+
using System.IO;
3+
using System.Threading;
4+
using NUnit.Framework;
5+
6+
namespace ServiceStack.Text.Tests.JsonTests
7+
{
8+
[TestFixture]
9+
public class ResponseStatusErrorTests
10+
{
11+
[Test, Explicit]
12+
public void Does_parse_ErrorResponse()
13+
{
14+
Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT");
15+
Thread.CurrentThread.CurrentUICulture = new CultureInfo("it-IT");
16+
17+
18+
var json = File.ReadAllText("~/_error.json".MapAbsolutePath());
19+
20+
var dto = json.FromJson<ErrorResponse>();
21+
22+
dto.PrintDump();
23+
}
24+
}
25+
}

tests/ServiceStack.Text.Tests/ServiceStack.Text.Tests.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
<Compile Include="JsonTests\AnonymousDeserializationTests.cs" />
199199
<Compile Include="JsonTests\ConditionalSerializationTests.cs" />
200200
<Compile Include="JsonTests\DictionaryDeserializationTests.cs" />
201+
<Compile Include="JsonTests\ResponseStatusErrorTests.cs" />
201202
<Compile Include="JsonTests\RouteValueDictionaryTests.cs" />
202203
<Compile Include="JsonTests\CustomRawSerializerTests.cs" />
203204
<Compile Include="JsonTests\CustomSerializerTests.cs" />
@@ -336,6 +337,11 @@
336337
<None Include="App.config" />
337338
<None Include="packages.config" />
338339
</ItemGroup>
340+
<ItemGroup>
341+
<None Include="_error.json">
342+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
343+
</None>
344+
</ItemGroup>
339345
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
340346
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
341347
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"responseStatus":{"errorCode":"SqlException","message":"The INSERT statement conflicted with the CHECK constraint \"CK_SOME_CONSTRAINT\". The conflict occurred in database \"TEST_XXX\", table \"dbo.SOME_TABLE\".\r\nThe statement has been terminated.","stackTrace":"[MyDTORequest: 19/02/2014 07:29:11]:\n[REQUEST: {idIstituto:xx,codice:cod,descrizione:c,flaG_F_O:F,iD_MERCATO:0,iD_TIPOLOGIA_PRODOTTO:101,iD_DIVISA:AED,iD_TIPO_REGOLAMENTO:0,iD_MARGIN_STYLE:0,iD_TIPO_RAPPRESENTAZIONE_PREZZO:0,iD_UTENTE:185560,iD_MACROCATEGORIA_COMMERCIALE:0,divisorE_PREZZO:0}]\nSystem.Data.SqlClient.SqlException (0x80131904): The INSERT statement conflicted with the CHECK constraint \"CK_CONSTRAINT\". The conflict occurred in database \"TEST_XXX\", table \"dbo.SOME_TABLE\".\r\nThe statement has been terminated.\r\n at MYNamespace.service.Any(MYDTORequest request) in cxxx.cs:line 163\r\n at ServiceStack.Host.ServiceRunner`1.Execute(IRequest request, Object instance, TRequest requestDto)\r\nClientConnectionId:53921837-e741-4a96-bd7e-5763b648b1b6","errors":[]}}

0 commit comments

Comments
 (0)