forked from ServiceStack/ServiceStack.Text
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceStack_Text_UseCase.cs
More file actions
40 lines (34 loc) · 1.25 KB
/
ServiceStack_Text_UseCase.cs
File metadata and controls
40 lines (34 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using NUnit.Framework;
namespace ServiceStack.Text.Tests.UseCases
{
public class GithubRepository
{
public string Name { get; set; }
public string Description { get; set; }
public string Url { get; set; }
public string Homepage { get; set; }
public string Language { get; set; }
public int Watchers { get; set; }
public int Forks { get; set; }
}
[TestFixture]
public class ServiceStack_Text_UseCase
{
[Test, Explicit]
public void Dump_and_Write_GitHub_Organization_Repos_to_CSV()
{
var orgName = "ServiceStack";
var orgRepos = "https://api.github.com/orgs/{0}/repos".Fmt(orgName)
.GetJsonFromUrl(httpReq => httpReq.UserAgent = "ServiceStack.Text")
.FromJson<List<GithubRepository>>();
"Writing {0} Github Repositories:".Print(orgName);
orgRepos.PrintDump(); //recursive, pretty-format dump of any C# POCOs
var csvFilePath = "~/{0}-repos.csv".Fmt(orgName).MapAbsolutePath();
File.WriteAllText(csvFilePath, orgRepos.ToCsv());
Process.Start(csvFilePath);
}
}
}