Skip to content

Commit e5648c2

Browse files
committed
Update tests.
1 parent 9bc01fd commit e5648c2

File tree

4 files changed

+158
-28
lines changed

4 files changed

+158
-28
lines changed

Applications/Ice/Tests/Cube.FileSystem.SevenZip.App.Ice.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
<Compile Include="Settings\ShortcutSettingsTest.cs" />
112112
<Compile Include="ArchiveTest.cs" />
113113
<Compile Include="ExtractTest.cs" />
114+
<Compile Include="PathConverterTest.cs" />
114115
<Compile Include="PresetMenuTest.cs" />
115116
<Compile Include="RequestTest.cs" />
116117
<Compile Include="ViewResourceTest.cs" />

Applications/Ice/Tests/Details/MockViewFactory.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ public override IProgressView CreateProgressView()
133133
/* ----------------------------------------------------------------- */
134134
public override void ShowSaveView(PathQueryEventArgs e)
135135
{
136+
var message = $"{e.Query}({e.Format})";
137+
Assert.That(e.Query, Is.Not.Null, message);
138+
136139
e.Cancel = string.IsNullOrEmpty(Settings.Destination);
137140
e.Result = Settings.Destination;
138141
}

Applications/Ice/Tests/ExtractTest.cs

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,31 @@ public void Extract_Rename()
114114

115115
/* ----------------------------------------------------------------- */
116116
///
117-
/// Extract_Cancel
117+
/// Extract_DeleteSource
118118
///
119119
/// <summary>
120-
/// 展開処理をキャンセルするテストを実行します
120+
/// 展開後に元の圧縮ファイルを削除するテストを実行します
121121
/// </summary>
122122
///
123123
/* ----------------------------------------------------------------- */
124124
[Test]
125-
public void Extract_Cancel()
125+
public void Extract_DeleteSource()
126126
{
127-
var src = Example("Complex.zip");
128-
var dest = Result("UserCancel");
127+
var src = Result("Complex.zip");
128+
var dest = Result("DeleteSource");
129+
var exists = Result(@"DeleteSource\Complex");
130+
131+
IO.Copy(Example("Complex.1.0.0.zip"), src);
129132

130133
using (var p = Create(src, dest))
131134
{
135+
p.Settings.Value.Extract.DeleteSource = true;
132136
p.View.Show();
133-
p.EventHub.GetEvents().Cancel.Publish();
134137
Assert.That(Wait(p.View).Result, Is.True, "Timeout");
135138
}
139+
140+
Assert.That(IO.Exists(src), Is.False, src);
141+
Assert.That(IO.Exists(exists), Is.True, exists);
136142
}
137143

138144
/* ----------------------------------------------------------------- */
@@ -174,31 +180,22 @@ public void Extract_Suspend()
174180

175181
/* ----------------------------------------------------------------- */
176182
///
177-
/// Extract_DeleteSource
183+
/// Extract_Cancel
178184
///
179185
/// <summary>
180-
/// 展開後に元の圧縮ファイルを削除するテストを実行します
186+
/// 展開処理をキャンセルするテストを実行します
181187
/// </summary>
182188
///
183189
/* ----------------------------------------------------------------- */
184190
[Test]
185-
public void Extract_DeleteSource()
191+
public void Extract_Cancel()
186192
{
187-
var src = Result("Complex.zip");
188-
var dest = Result("DeleteSource");
189-
var exists = Result(@"DeleteSource\Complex");
190-
191-
IO.Copy(Example("Complex.1.0.0.zip"), src);
192-
193-
using (var p = Create(src, dest))
193+
using (var p = Create(Example("Complex.zip"), ""))
194194
{
195-
p.Settings.Value.Extract.DeleteSource = true;
196195
p.View.Show();
196+
p.EventHub.GetEvents().Cancel.Publish();
197197
Assert.That(Wait(p.View).Result, Is.True, "Timeout");
198198
}
199-
200-
Assert.That(IO.Exists(src), Is.False, src);
201-
Assert.That(IO.Exists(exists), Is.True, exists);
202199
}
203200

204201
/* ----------------------------------------------------------------- */
@@ -213,10 +210,7 @@ public void Extract_DeleteSource()
213210
[Test]
214211
public void Extract_PasswordCancel()
215212
{
216-
var src = Example("Password.7z");
217-
var dest = Result("PasswordCancel");
218-
219-
using (var p = Create(src, dest))
213+
using (var p = Create(Example("Password.7z"), ""))
220214
{
221215
p.View.Show();
222216
Assert.That(Wait(p.View).Result, Is.True, "Timeout");
@@ -235,10 +229,7 @@ public void Extract_PasswordCancel()
235229
[Test]
236230
public void Extract_ErrorReport()
237231
{
238-
var src = Example("Sample.txt");
239-
var dest = Result("ErrorReport");
240-
241-
using (var p = Create(src, dest))
232+
using (var p = Create(Example("Sample.txt"), ""))
242233
{
243234
p.Settings.Value.ErrorReport = true;
244235
p.View.Show();
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/* ------------------------------------------------------------------------- */
2+
//
3+
// Copyright (c) 2010 CubeSoft, Inc.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
//
17+
/* ------------------------------------------------------------------------- */
18+
using System.Collections.Generic;
19+
using NUnit.Framework;
20+
21+
namespace Cube.FileSystem.SevenZip.App.Ice.Tests
22+
{
23+
/* --------------------------------------------------------------------- */
24+
///
25+
/// PathConverterTest
26+
///
27+
/// <summary>
28+
/// PathConverter のテスト用クラスです。
29+
/// </summary>
30+
///
31+
/* --------------------------------------------------------------------- */
32+
[TestFixture]
33+
class PathConverterTest
34+
{
35+
#region Tests
36+
37+
/* ----------------------------------------------------------------- */
38+
///
39+
/// CompressionMethod_Default
40+
///
41+
/// <summary>
42+
/// CompressionMethod の初期値を確認します。
43+
/// </summary>
44+
///
45+
/* ----------------------------------------------------------------- */
46+
[Test]
47+
public void CompressionMethod_Default()
48+
{
49+
var cvt = new PathConverter(@"c:\foo\bar\src.txt", Format.Zip);
50+
Assert.That(cvt.CompressionMethod, Is.EqualTo(CompressionMethod.Default));
51+
}
52+
53+
/* ----------------------------------------------------------------- */
54+
///
55+
/// Convert
56+
///
57+
/// <summary>
58+
/// 変換処理のテストを実行します。
59+
/// </summary>
60+
///
61+
/* ----------------------------------------------------------------- */
62+
[TestCaseSource(nameof(TestCases))]
63+
public string Convert(string src, Format format, CompressionMethod method)
64+
=> new PathConverter(src, format, method).Result.FullName;
65+
66+
#endregion
67+
68+
#region TestCases
69+
70+
/* ----------------------------------------------------------------- */
71+
///
72+
/// TestCases
73+
///
74+
/// <summary>
75+
/// テスト用データを取得します。
76+
/// </summary>
77+
///
78+
/* ----------------------------------------------------------------- */
79+
private static IEnumerable<TestCaseData> TestCases
80+
{
81+
get
82+
{
83+
yield return new TestCaseData(
84+
@"c:\foo\bar\test.txt",
85+
Format.Zip,
86+
CompressionMethod.Deflate
87+
).Returns(@"c:\foo\bar\test.zip");
88+
89+
yield return new TestCaseData(
90+
@"c:\foo\bar\test.exe.config",
91+
Format.SevenZip,
92+
CompressionMethod.Lzma
93+
).Returns(@"c:\foo\bar\test.exe.7z");
94+
95+
yield return new TestCaseData(
96+
@"c:\foo\bar\test.tar.gz",
97+
Format.Sfx,
98+
CompressionMethod.Lzma2
99+
).Returns(@"c:\foo\bar\test.exe");
100+
101+
yield return new TestCaseData(
102+
@"c:\foo\bar\test.txt",
103+
Format.GZip,
104+
CompressionMethod.Default
105+
).Returns(@"c:\foo\bar\test.tar.gz");
106+
107+
yield return new TestCaseData(
108+
@"c:\foo\bar\test.txt",
109+
Format.Tar,
110+
CompressionMethod.Copy
111+
).Returns(@"c:\foo\bar\test.tar");
112+
113+
yield return new TestCaseData(
114+
@"c:\foo\bar\test.txt",
115+
Format.Tar,
116+
CompressionMethod.GZip
117+
).Returns(@"c:\foo\bar\test.tar.gz");
118+
119+
yield return new TestCaseData(
120+
@"c:\foo\bar\test.txt",
121+
Format.Tar,
122+
CompressionMethod.BZip2
123+
).Returns(@"c:\foo\bar\test.tar.bz2");
124+
125+
yield return new TestCaseData(
126+
@"c:\foo\bar\test.txt",
127+
Format.Tar,
128+
CompressionMethod.XZ
129+
).Returns(@"c:\foo\bar\test.tar.xz");
130+
}
131+
}
132+
133+
#endregion
134+
}
135+
}

0 commit comments

Comments
 (0)