• R/O
  • SSH
  • HTTPS

moneyimport: Commit


Commit MetaInfo

Revision209 (tree)
Zeit2008-05-31 21:00:19
Autortmurakam

Log Message

update unittest

Ändern Zusammenfassung

Diff

--- trunk/FeliCa2Money.net/FeliCa2Money.test/Class1.cs (revision 208)
+++ trunk/FeliCa2Money.net/FeliCa2Money.test/Class1.cs (nonexistent)
@@ -1,20 +0,0 @@
1-using System;
2-using System.Collections.Generic;
3-using System.Text;
4-
5-using NUnit.Framework;
6-using FeliCa2Money;
7-
8-namespace FeliCa2Money.test
9-{
10- [TestFixture]
11- public class EdyTest
12- {
13- [Test]
14- public void test1()
15- {
16- FeliCa2Money.Edy c = new FeliCa2Money.Edy();
17- }
18-
19- }
20-}
--- trunk/FeliCa2Money.net/FeliCa2Money.test/EdyTest.cs (nonexistent)
+++ trunk/FeliCa2Money.net/FeliCa2Money.test/EdyTest.cs (revision 209)
@@ -0,0 +1,43 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Text;
4+
5+using NUnit.Framework;
6+using FeliCa2Money;
7+using FelicaLib;
8+
9+namespace FeliCa2Money.test
10+{
11+ [TestFixture]
12+ public class EdyTest
13+ {
14+ DummyFelica f;
15+
16+ [SetUp]
17+ public void Setup()
18+ {
19+ f = new DummyFelica();
20+ f.SetSystemCode((int)SystemCode.Edy);
21+
22+ // set card id
23+ byte[] d;
24+ d = new byte[] { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
25+ f.SetTestData(0x110b, d);
26+ }
27+
28+ [TearDown]
29+ public void TearDown()
30+ {
31+ f = null;
32+ }
33+
34+ [Test]
35+ public void analyzeCardId()
36+ {
37+ FeliCa2Money.Edy c = new FeliCa2Money.Edy();
38+ c.analyzeCardId(f);
39+
40+ Assert.AreEqual(c.AccountId, "456789ABCDEF0123");
41+ }
42+ }
43+}
--- trunk/FeliCa2Money.net/FeliCa2Money.test/FelicaLibDummy.cs (revision 208)
+++ trunk/FeliCa2Money.net/FeliCa2Money.test/FelicaLibDummy.cs (revision 209)
@@ -1,4 +1,5 @@
11 using System;
2+using System.Collections;
23 using System.Collections.Generic;
34 using System.Text;
45
@@ -6,8 +7,9 @@
67 {
78 public class DummyFelica : IFelica
89 {
9- private byte[] dataBuf = null;
10+ private Hashtable dataBufs = new Hashtable();
1011 private int pos = 0;
12+ private int systemCode;
1113
1214 public DummyFelica()
1315 {
@@ -16,12 +18,12 @@
1618
1719 public void Dispose()
1820 {
19- // do nothing
21+ dataBufs = null;
2022 }
2123
22- public void Polling(int systemcode)
24+ public void Polling(int s)
2325 {
24- pos = 0;
26+ systemCode = s;
2527 }
2628
2729 public byte[] IDm()
@@ -44,11 +46,12 @@
4446 return buf;
4547 }
4648
47- public byte[] ReadWithoutEncryption(int servicecode, int addr)
49+ public byte[] ReadWithoutEncryption(int sv, int addr)
4850 {
49- byte[] data = new byte[16];
51+ byte[] ret = new byte[16];
52+ byte[] data = (byte[])dataBufs[systemCode << 16 | sv];
5053
51- if (pos > data.Length)
54+ if (data == null || data.Length < (addr + 1) * 16)
5255 {
5356 return null;
5457 }
@@ -55,15 +58,22 @@
5558
5659 for (int i = 0; i < 16; i++)
5760 {
58- data[i] = dataBuf[pos + i];
61+ ret[i] = data[addr * 16 + i];
5962 }
6063 pos += 16;
6164 return data;
6265 }
6366
64- public void SetTestData(byte[] data)
67+ // set data
68+
69+ public void SetSystemCode(int s)
6570 {
66- dataBuf = data;
71+ systemCode = s;
6772 }
73+
74+ public void SetTestData(int sv, byte[] data)
75+ {
76+ dataBufs[systemCode << 16 | sv] = data;
77+ }
6878 }
6979 }
--- trunk/FeliCa2Money.net/FelicaLib.cs (revision 208)
+++ trunk/FeliCa2Money.net/FelicaLib.cs (revision 209)
@@ -6,7 +6,7 @@
66 namespace FelicaLib
77 {
88 // システムコード
9- enum SystemCode : int
9+ public enum SystemCode : int
1010 {
1111 Any = 0xffff, // ANY
1212 Common = 0xfe00, // 共通領域
Show on old repository browser