|
| 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