-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 파일명 치환 - 하위문자열
- Loading branch information
Showing
6 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>disable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
<DefineConstants>TRACE;UNIT_TEST</DefineConstants> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
<DefineConstants>TRACE;UNIT_TEST</DefineConstants> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" /> | ||
<PackageReference Include="coverlet.collector" Version="3.1.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\DaramRenamer.Commands\DaramRenamer.Commands.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Diagnostics; | ||
using DaramRenamer.Commands.Filename; | ||
|
||
namespace DaramRenamer.Test; | ||
|
||
[TestClass] | ||
public class FilenameUnitTest | ||
{ | ||
[TestMethod] | ||
public void ReplacePlainCommandTest() | ||
{ | ||
var testFile1 = TestUtil.MakeFileInfo(@"C:\PathA.txt"); | ||
|
||
var command1 = new ReplacePlainCommand | ||
{ | ||
Find = "a", | ||
Replace = "b", | ||
IncludeExtension = false | ||
}; | ||
command1.DoCommand(testFile1); | ||
|
||
Assert.IsTrue(testFile1.ChangedFilename == "PbthA.txt"); | ||
|
||
testFile1.Reset(); | ||
|
||
var command2 = new ReplacePlainCommand | ||
{ | ||
Find = "t", | ||
Replace = "r", | ||
IncludeExtension = true | ||
}; | ||
command2.DoCommand(testFile1); | ||
|
||
Assert.IsTrue(testFile1.ChangedFilename == "ParhA.rxr"); | ||
} | ||
|
||
[TestMethod] | ||
public void SubstringCommand() | ||
{ | ||
var testFile1 = TestUtil.MakeFileInfo(@"C:\Path.txt"); | ||
var testFile2 = TestUtil.MakeFileInfo(@"C:\Finder.txt"); | ||
|
||
var command1 = new SubstringCommand | ||
{ | ||
StartIndex = 2, | ||
Length = 3, | ||
IncludeExtension = false | ||
}; | ||
|
||
command1.DoCommand(testFile1, testFile2); | ||
|
||
Debug.Write(testFile1.ChangedFilename); | ||
Assert.IsTrue(testFile1.ChangedFilename == "th.txt"); | ||
|
||
Debug.Write(testFile2.ChangedFilename); | ||
Assert.IsTrue(testFile2.ChangedFilename == "nde.txt"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace DaramRenamer.Test; | ||
|
||
public static class TestUtil | ||
{ | ||
public static FileInfo MakeFileInfo(string fullPath) | ||
{ | ||
return new FileInfo(fullPath, directoryCheck: false); | ||
} | ||
|
||
public static void DoCommand(this ICommand command, params FileInfo[] fileInfos) | ||
{ | ||
foreach (var fileInfo in fileInfos) | ||
command.DoCommand(fileInfo); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Microsoft.VisualStudio.TestTools.UnitTesting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters