Skip to content

Commit

Permalink
added hypothesis testcase: createdirectory followed by createasset do…
Browse files Browse the repository at this point in the history
…es not necessity importing the folder
  • Loading branch information
CodeSmile-0000011110110111 committed Feb 9, 2024
1 parent d4264f1 commit 76e19c0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Tests/Editor/AssetCtorCreateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NUnit.Framework;
using System;
using System.Text;
using UnityEditor;
using UnityEngine.UIElements;
using Object = UnityEngine.Object;

Expand Down Expand Up @@ -147,5 +148,22 @@ [Test] public void CreateAsNewStatic_ByteArray_CreatesAndImportsAsset()
Assert.True(Asset.Status.IsImported(path));
Assert.True(obj is ThemeStyleSheet);
}

// Verifying a theory that creating a new folder and subsequently creating an asset within
// does not actually require to import the new folder.
[Test] public void CreateStatic_InCreatedButNotImportedDirectory_CreatesAssetAndFolderIsImported()
{
Assert.False(System.IO.Directory.Exists(TestSubFolderPath));
System.IO.Directory.CreateDirectory(TestSubFolderPath);

var assetPath = TestSubFolderPath + "/test-so.asset";
var so = Instantiate.ExampleSO();

AssetDatabase.CreateAsset(so, assetPath);

Assert.True(Asset.Path.FileExists(assetPath));
Assert.True(Asset.Status.IsImported(TestSubFolderPath));
Assert.True(Asset.Status.IsImported(assetPath));
}
}
}

0 comments on commit 76e19c0

Please sign in to comment.