Mercurial > silverbladetech
comparison Stocks/Stocks.Common.Tests.Unit/Core/SerializerTests.cs @ 0:e5d46bb6cdb0
Initial commit
author | adminSH stevenhollidge@hotmail.com |
---|---|
date | Mon, 20 Feb 2012 13:52:35 +0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e5d46bb6cdb0 |
---|---|
1 using System; | |
2 using System.Collections.Generic; | |
3 using System.Linq; | |
4 using System.Text; | |
5 using Xunit; | |
6 using Stocks.Common.Core; | |
7 using Stocks.Common.Models; | |
8 using System.IO; | |
9 | |
10 namespace Stocks.Common.Tests.Unit.Core | |
11 { | |
12 public class SerializerTests | |
13 { | |
14 [Fact] | |
15 public void Test() | |
16 { | |
17 string filename = "companyData.json"; | |
18 List<Company> expected; | |
19 List<Company> actual; | |
20 | |
21 try | |
22 { | |
23 var file = "../../../Stocks.Service/companyData.json"; | |
24 var configurationService = new ConfigurationService(file); | |
25 expected = configurationService.GetCompanies(); | |
26 | |
27 var worker = new FileSerializer(); | |
28 worker.SerializeJson(filename, expected); | |
29 | |
30 actual = worker.DeserializeJson<Company>(filename); | |
31 } | |
32 finally | |
33 { | |
34 if (File.Exists(filename)) | |
35 File.Delete(filename); | |
36 } | |
37 | |
38 Assert.Equal(expected.Count, actual.Count); | |
39 | |
40 for (int i = 0; i < actual.Count; i++) | |
41 { | |
42 Assert.Equal(expected[i].Symbol, actual[i].Symbol); | |
43 Assert.Equal(expected[i].Name, actual[i].Name); | |
44 } | |
45 } | |
46 | |
47 // return new List<Company> | |
48 //{ | |
49 // new Company() { Symbol = "AAPL", Name = "Apple, Inc" }, | |
50 // new Company() { Symbol = "AXP", Name = "American Express Company" }, | |
51 // new Company() { Symbol = "BAC", Name = "Bank of America Corporation" }, | |
52 // new Company() { Symbol = "CSCO", Name = "Cisco Systems, Inc" }, | |
53 // new Company() { Symbol = "DIS", Name = "Walt Disney Company" }, | |
54 // new Company() { Symbol = "GE", Name = "General Electric Company" }, | |
55 // new Company() { Symbol = "GOOG", Name = "Google" }, | |
56 // new Company() { Symbol = "HPQ", Name = "Hewlett-Packard Company" }, | |
57 // new Company() { Symbol = "INTC", Name = "Intel Corporation" }, | |
58 // new Company() { Symbol = "JPM", Name = "JP Morgan Chase & Co" }, | |
59 // new Company() { Symbol = "KO", Name = "Coca-Cola Company" }, | |
60 // new Company() { Symbol = "MSFT", Name = "Microsoft Corporation" }, | |
61 // new Company() { Symbol = "PFE", Name = "Pfizer, Inc." }, | |
62 // new Company() { Symbol = "T", Name = "AT&T Inc." }, | |
63 // new Company() { Symbol = "UTX", Name = "United Technologies Corporation" }, | |
64 // new Company() { Symbol = "VZ", Name = "Verizon Communications Inc." }, | |
65 // new Company() { Symbol = "WMT", Name = "Wal-Mart Stores, Inc." }, | |
66 // new Company() { Symbol = "XOM", Name = "Exxon Mobil Corporation" } | |
67 //}; | |
68 } | |
69 } |