1
- // Copyright (c) 2021-2023 Koji Hasegawa.
1
+ // Copyright (c) 2021-2025 Koji Hasegawa.
2
2
// This software is released under the MIT License.
3
3
4
4
using System ;
11
11
using UnityEngine ;
12
12
using UnityEngine . TestTools ;
13
13
using AssertionException = UnityEngine . Assertions . AssertionException ;
14
- #if UNITY_EDITOR
15
- using UnityEditor ;
16
- #endif
17
14
18
15
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
19
16
@@ -315,7 +312,7 @@ public void HasCount_コレクションの個数を検証()
315
312
[ Test ]
316
313
public void HasLength_配列の個数を検証 ( )
317
314
{
318
- var actual = new int [ ] { 2 , 3 , 5 , 6 } ;
315
+ var actual = new [ ] { 2 , 3 , 5 , 6 } ;
319
316
Assert . That ( actual , Has . Length . EqualTo ( 4 ) ) ;
320
317
// 失敗時メッセージ例:
321
318
// Expected: property Length equal to 4
@@ -539,8 +536,10 @@ public class ファイルとディレクトリ
539
536
[ UnityPlatform ( RuntimePlatform . LinuxEditor , RuntimePlatform . WindowsEditor , RuntimePlatform . OSXEditor ) ]
540
537
public void EmptyDirectoryConstraint_ディレクトリが空であること ( )
541
538
{
542
- #if UNITY_EDITOR
543
- var dir = FileUtil . GetUniqueTempPathInProject ( ) ;
539
+ var dir = Path . Combine (
540
+ Application . temporaryCachePath ,
541
+ TestContext . CurrentContext . Test . ClassName ,
542
+ TestContext . CurrentContext . Test . Name ) ;
544
543
var actual = Directory . CreateDirectory ( dir ) ;
545
544
546
545
Assert . That ( actual , Is . Empty ) ;
@@ -549,15 +548,16 @@ public void EmptyDirectoryConstraint_ディレクトリが空であること()
549
548
// But was: <UnityTempFile-113d9721b8aa84bb0a7bf0b6e31e2638>
550
549
551
550
Directory . Delete ( dir , true ) ;
552
- #endif
553
551
}
554
552
555
553
[ Test ]
556
554
[ UnityPlatform ( RuntimePlatform . LinuxEditor , RuntimePlatform . WindowsEditor , RuntimePlatform . OSXEditor ) ]
557
555
public void FileOrDirectoryExistsConstraint_ファイルまたはディレクトリが存在すること ( )
558
556
{
559
- #if UNITY_EDITOR
560
- var dir = Path . GetFileName ( FileUtil . GetUniqueTempPathInProject ( ) ) ;
557
+ var dir = Path . Combine (
558
+ Application . temporaryCachePath ,
559
+ TestContext . CurrentContext . Test . ClassName ,
560
+ TestContext . CurrentContext . Test . Name ) ;
561
561
var directoryInfo = Directory . CreateDirectory ( dir ) ;
562
562
var file = Path . Combine ( dir , "test" ) ;
563
563
var fileInfo = new FileInfo ( file ) ;
@@ -575,7 +575,6 @@ public void FileOrDirectoryExistsConstraint_ファイルまたはディレクト
575
575
// But was: "Temp/UnityTempFile-ac03ee62865a042748c6f54723c2e51b/test"
576
576
577
577
Directory . Delete ( dir , true ) ;
578
- #endif
579
578
}
580
579
581
580
[ Test ]
0 commit comments