| 1 |
Imports Microsoft.VisualStudio.TestTools.UnitTesting |
| 2 |
|
| 3 |
Imports ShogiNextMove.Board |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
'''<summary> |
| 8 |
'''KyokumenTest のテスト クラスです。すべての |
| 9 |
'''KyokumenTest 単体テストをここに含めます |
| 10 |
'''</summary> |
| 11 |
<TestClass()> _ |
| 12 |
Public Class KyokumenTest |
| 13 |
|
| 14 |
|
| 15 |
Private testContextInstance As TestContext |
| 16 |
|
| 17 |
'''<summary> |
| 18 |
'''現在のテストの実行についての情報および機能を |
| 19 |
'''提供するテスト コンテキストを取得または設定します。 |
| 20 |
'''</summary> |
| 21 |
Public Property TestContext() As TestContext |
| 22 |
Get |
| 23 |
Return testContextInstance |
| 24 |
End Get |
| 25 |
Set(value As TestContext) |
| 26 |
testContextInstance = Value |
| 27 |
End Set |
| 28 |
End Property |
| 29 |
|
| 30 |
#Region "追加のテスト属性" |
| 31 |
' |
| 32 |
'テストを作成するときに、次の追加属性を使用することができます: |
| 33 |
' |
| 34 |
'クラスの最初のテストを実行する前にコードを実行するには、ClassInitialize を使用 |
| 35 |
'<ClassInitialize()> _ |
| 36 |
'Public Shared Sub MyClassInitialize(ByVal testContext As TestContext) |
| 37 |
'End Sub |
| 38 |
' |
| 39 |
'クラスのすべてのテストを実行した後にコードを実行するには、ClassCleanup を使用 |
| 40 |
'<ClassCleanup()> _ |
| 41 |
'Public Shared Sub MyClassCleanup() |
| 42 |
'End Sub |
| 43 |
' |
| 44 |
'各テストを実行する前にコードを実行するには、TestInitialize を使用 |
| 45 |
'<TestInitialize()> _ |
| 46 |
'Public Sub MyTestInitialize() |
| 47 |
'End Sub |
| 48 |
' |
| 49 |
'各テストを実行した後にコードを実行するには、TestCleanup を使用 |
| 50 |
'<TestCleanup()> _ |
| 51 |
'Public Sub MyTestCleanup() |
| 52 |
'End Sub |
| 53 |
' |
| 54 |
#End Region |
| 55 |
|
| 56 |
|
| 57 |
'''<summary> |
| 58 |
'''ToggleTurn のテスト |
| 59 |
'''</summary> |
| 60 |
<TestMethod()> _ |
| 61 |
Public Sub ToggleTurnTest() |
| 62 |
Dim target As Kyokumen = New Kyokumen() ' TODO: 適切な値に初期化してください |
| 63 |
Assert.AreEqual(Koma.SENTE, target.Turn) |
| 64 |
target.ToggleTurn() |
| 65 |
Assert.AreEqual(Koma.GOTE, target.Turn) |
| 66 |
target.ToggleTurn() |
| 67 |
Assert.AreEqual(Koma.SENTE, target.Turn) |
| 68 |
|
| 69 |
End Sub |
| 70 |
|
| 71 |
'''<summary> |
| 72 |
'''Kyokumen コンストラクター のテスト |
| 73 |
'''</summary> |
| 74 |
<TestMethod()> _ |
| 75 |
Public Sub KyokumenConstructorTest() |
| 76 |
Dim target As Kyokumen = New Kyokumen() |
| 77 |
Assert.AreEqual(True, KyokumenHaichiComp.HaichiIsEqual(target, New Haichi.Hirate)) |
| 78 |
For KomaValueWithWhich As Byte = Koma.SENTE_FU To Koma.SENTE_HISYA |
| 79 |
Assert.AreEqual(0, target.Hand(KomaValueWithWhich)) |
| 80 |
Next |
| 81 |
For komaValueWithWhich As Byte = Koma.GOTE_FU To Koma.GOTE_HISYA |
| 82 |
Assert.AreEqual(0, target.Hand(komaValueWithWhich)) |
| 83 |
Next |
| 84 |
End Sub |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
'''<summary> |
| 89 |
'''GetMasu のテスト |
| 90 |
'''</summary> |
| 91 |
<TestMethod()> _ |
| 92 |
Public Sub GetMasuTest() |
| 93 |
Dim target As Kyokumen = New Kyokumen() |
| 94 |
Assert.AreEqual(Koma.GOTE_OU, target.GetMasu(5, 1).Value) |
| 95 |
Assert.AreEqual(Koma.GOTE_KAKU, target.GetMasu(2, 2).Value) |
| 96 |
Assert.AreEqual(Koma.GOTE_HISYA, target.GetMasu(8, 2).Value) |
| 97 |
|
| 98 |
Assert.AreEqual(Koma.SENTE_GYOKU, target.GetMasu(5, 9).Value) |
| 99 |
Assert.AreEqual(Koma.SENTE_KAKU, target.GetMasu(8, 8).Value) |
| 100 |
Assert.AreEqual(Koma.SENTE_HISYA, target.GetMasu(2, 8).Value) |
| 101 |
|
| 102 |
End Sub |
| 103 |
|
| 104 |
'''<summary> |
| 105 |
'''Edit のテスト |
| 106 |
'''</summary> |
| 107 |
<TestMethod()> _ |
| 108 |
Public Sub EditTest() |
| 109 |
Dim target As Kyokumen = New Kyokumen() ' TODO: 適切な値に初期化してください |
| 110 |
Dim fromLocation As KomaLocation = New KomaLocation(3, 3) |
| 111 |
Dim toLocation As KomaLocation = New KomaLocation(3, 4) |
| 112 |
Dim te As Te = New Te(fromLocation, toLocation, Koma.GOTE_FU, False) |
| 113 |
Assert.AreEqual(CByte(0), target.GetMasu(toLocation).Value ) |
| 114 |
Assert.AreEqual(Koma.GOTE_FU, target.GetMasu(fromLocation).Value) |
| 115 |
target.Edit(te) |
| 116 |
Assert.AreEqual(Koma.GOTE_FU, target.GetMasu(toLocation).Value) |
| 117 |
Assert.AreEqual(CByte(0), target.GetMasu(fromLocation).Value) |
| 118 |
|
| 119 |
End Sub |
| 120 |
|
| 121 |
'''<summary> |
| 122 |
'''KomabakoCounts のテスト |
| 123 |
'''</summary> |
| 124 |
<TestMethod()> _ |
| 125 |
Public Sub KomabakoCountsTest1() |
| 126 |
Dim target As Kyokumen = New Kyokumen() |
| 127 |
Dim te1 As Te = New Te(New KomaLocation(7, 7), New KomaLocation(7, 6), Koma.SENTE_FU, False) |
| 128 |
Dim te2 As Te = New Te(New KomaLocation(3, 3), New KomaLocation(3, 4), Koma.GOTE_FU, False) |
| 129 |
Dim te3 As Te = New Te(New KomaLocation(8, 8), New KomaLocation(2, 2), Koma.SENTE_UMA, True) |
| 130 |
target.Edit(te1) |
| 131 |
target.Edit(te2) |
| 132 |
target.Edit(te3) |
| 133 |
Dim actual() As Integer = target.KomabakoCounts |
| 134 |
Assert.AreEqual(Koma.C_KOMABAKO_MAX + 1, actual.Length) |
| 135 |
Assert.AreEqual(0, actual(Koma.C_HISYA)) |
| 136 |
Assert.AreEqual(0, actual(Koma.C_KAKU)) |
| 137 |
Assert.AreEqual(0, actual(Koma.C_KIN)) |
| 138 |
Assert.AreEqual(0, actual(Koma.C_GIN)) |
| 139 |
Assert.AreEqual(0, actual(Koma.C_KEI)) |
| 140 |
Assert.AreEqual(0, actual(Koma.C_KYO)) |
| 141 |
Assert.AreEqual(0, actual(Koma.C_FU)) |
| 142 |
Assert.AreEqual(0, actual(Koma.C_GYOKU)) |
| 143 |
Assert.AreEqual(0, actual(Koma.C_OU)) |
| 144 |
End Sub |
| 145 |
|
| 146 |
'''<summary> |
| 147 |
'''KomabakoCounts のテスト |
| 148 |
'''</summary> |
| 149 |
<TestMethod()> _ |
| 150 |
Public Sub KomabakoCountsTest3() |
| 151 |
Dim target As Kyokumen = New Kyokumen() |
| 152 |
Dim te1 As Te = New Te(New KomaLocation(7, 7), New KomaLocation(7, 6), Koma.SENTE_FU, False) |
| 153 |
Dim te2 As Te = New Te(New KomaLocation(3, 3), New KomaLocation(3, 4), Koma.GOTE_FU, False) |
| 154 |
Dim te3 As Te = New Te(New KomaLocation(8, 8), New KomaLocation(2, 2), Koma.SENTE_UMA, True) |
| 155 |
Dim te4 As Te = New Te(New KomaLocation(3, 1), New KomaLocation(2, 2), Koma.GOTE_GIN, False) |
| 156 |
target.Edit(te1) |
| 157 |
target.Edit(te2) |
| 158 |
target.Edit(te3) |
| 159 |
target.Edit(te4) |
| 160 |
Dim actual() As Integer = target.KomabakoCounts |
| 161 |
Assert.AreEqual(Koma.C_KOMABAKO_MAX + 1, actual.Length) |
| 162 |
Assert.AreEqual(0, actual(Koma.C_HISYA)) |
| 163 |
Assert.AreEqual(0, actual(Koma.C_KAKU)) |
| 164 |
Assert.AreEqual(0, actual(Koma.C_KIN)) |
| 165 |
Assert.AreEqual(0, actual(Koma.C_GIN)) |
| 166 |
Assert.AreEqual(0, actual(Koma.C_KEI)) |
| 167 |
Assert.AreEqual(0, actual(Koma.C_KYO)) |
| 168 |
Assert.AreEqual(0, actual(Koma.C_FU)) |
| 169 |
Assert.AreEqual(0, actual(Koma.C_GYOKU)) |
| 170 |
Assert.AreEqual(0, actual(Koma.C_OU)) |
| 171 |
End Sub |
| 172 |
|
| 173 |
'''<summary> |
| 174 |
'''KomabakoCounts のテスト |
| 175 |
'''</summary> |
| 176 |
<TestMethod()> _ |
| 177 |
Public Sub KomabakoCountsTest2() |
| 178 |
Dim target As Kyokumen = New Kyokumen() |
| 179 |
Dim te1 As Te = New Te(New KomaLocation(7, 7), KomaLocation.KomaBako, Koma.SENTE_FU, False) |
| 180 |
Dim te2 As Te = New Te(New KomaLocation(3, 3), KomaLocation.KomaBako, Koma.GOTE_FU, False) |
| 181 |
Dim te3 As Te = New Te(New KomaLocation(8, 8), KomaLocation.KomaBako, Koma.SENTE_KAKU, True) |
| 182 |
target.Edit(te1) |
| 183 |
target.Edit(te2) |
| 184 |
target.Edit(te3) |
| 185 |
Dim actual() As Integer = target.KomabakoCounts |
| 186 |
Assert.AreEqual(Koma.C_KOMABAKO_MAX + 1, actual.Length) |
| 187 |
Assert.AreEqual(0, actual(Koma.C_HISYA)) |
| 188 |
Assert.AreEqual(1, actual(Koma.C_KAKU)) |
| 189 |
Assert.AreEqual(0, actual(Koma.C_KIN)) |
| 190 |
Assert.AreEqual(0, actual(Koma.C_GIN)) |
| 191 |
Assert.AreEqual(0, actual(Koma.C_KEI)) |
| 192 |
Assert.AreEqual(0, actual(Koma.C_KYO)) |
| 193 |
Assert.AreEqual(2, actual(Koma.C_FU)) |
| 194 |
Assert.AreEqual(0, actual(Koma.C_GYOKU)) |
| 195 |
Assert.AreEqual(0, actual(Koma.C_OU)) |
| 196 |
End Sub |
| 197 |
|
| 198 |
'''<summary> |
| 199 |
'''KomabakoCounts のテスト |
| 200 |
'''</summary> |
| 201 |
<TestMethod()> _ |
| 202 |
Public Sub KomabakoCountsTest() |
| 203 |
Dim target As Kyokumen = New Kyokumen(New Haichi.Jumaiochi) |
| 204 |
Dim actual() As Integer = target.KomabakoCounts |
| 205 |
Assert.AreEqual(Koma.C_KOMABAKO_MAX + 1, actual.Length) |
| 206 |
Assert.AreEqual(1, actual(Koma.C_HISYA)) |
| 207 |
Assert.AreEqual(1, actual(Koma.C_KAKU)) |
| 208 |
Assert.AreEqual(2, actual(Koma.C_KIN)) |
| 209 |
Assert.AreEqual(2, actual(Koma.C_GIN)) |
| 210 |
Assert.AreEqual(2, actual(Koma.C_KEI)) |
| 211 |
Assert.AreEqual(2, actual(Koma.C_KYO)) |
| 212 |
Assert.AreEqual(0, actual(Koma.C_FU)) |
| 213 |
Assert.AreEqual(0, actual(Koma.C_GYOKU)) |
| 214 |
Assert.AreEqual(0, actual(Koma.C_OU)) |
| 215 |
End Sub |
| 216 |
End Class |