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

Commit 2604e11

Browse files
committed
Add UseCase for ServiceStack.Text product
1 parent d5c96d7 commit 2604e11

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@
280280
<Compile Include="UseCases\StripeJsonData.cs" />
281281
<Compile Include="UseCases\StripeGateway.cs" />
282282
<Compile Include="UseCases\StripeSerializationTests.cs" />
283+
<Compile Include="UseCases\ServiceStack_Text_UseCase.cs" />
283284
<Compile Include="Utils\DateTimeSerializerTests.cs" />
284285
<Compile Include="Support\DdnDtos.cs" />
285286
<Compile Include="DdnDtoTests.cs" />
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Collections.Generic;
2+
using System.Diagnostics;
3+
using System.IO;
4+
using NUnit.Framework;
5+
6+
namespace ServiceStack.Text.Tests.UseCases
7+
{
8+
public class GithubRepository
9+
{
10+
public string Name { get; set; }
11+
public string Description { get; set; }
12+
public string Url { get; set; }
13+
public string Homepage { get; set; }
14+
public string Language { get; set; }
15+
public int Watchers { get; set; }
16+
public int Forks { get; set; }
17+
}
18+
19+
[TestFixture]
20+
public class ServiceStack_Text_UseCase
21+
{
22+
[Test, Explicit]
23+
public void Dump_and_Write_GitHub_Organization_Repos_to_CSV()
24+
{
25+
var orgName = "ServiceStack";
26+
27+
var orgRepos = "https://api.github.com/orgs/{0}/repos".Fmt(orgName)
28+
.GetJsonFromUrl(httpReq => httpReq.UserAgent = "ServiceStack.Text")
29+
.FromJson<List<GithubRepository>>();
30+
31+
"Writing {0} Github Repositories:".Print(orgName);
32+
orgRepos.PrintDump(); //recursive, pretty-format dump of any C# POCOs
33+
34+
var csvFilePath = "~/{0}-repos.csv".Fmt(orgName).MapAbsolutePath();
35+
File.WriteAllText(csvFilePath, orgRepos.ToCsv());
36+
37+
Process.Start(csvFilePath);
38+
}
39+
}
40+
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ public TestModel()
7777
public void Can_DumpModel()
7878
{
7979
var model = new TestModel();
80-
Console.WriteLine(model.Dump());
80+
model.PrintDump();
8181
}
82-
8382
}
8483
}

0 commit comments

Comments
 (0)