diff --git a/sources/assets/Stride.Core.Assets.Tests/TestFileVersionManager.cs b/sources/assets/Stride.Core.Assets.Tests/TestFileVersionManager.cs index 57a70e9604..a6ac83bd80 100644 --- a/sources/assets/Stride.Core.Assets.Tests/TestFileVersionManager.cs +++ b/sources/assets/Stride.Core.Assets.Tests/TestFileVersionManager.cs @@ -7,6 +7,7 @@ using Xunit; using Stride.Core.IO; using Stride.Core.Storage; +using System.Threading.Tasks; namespace Stride.Core.Assets.Tests { @@ -43,7 +44,7 @@ public void Test() [Fact] - public void TestAsync() + public async Task TestAsync() { var files = new List(); for (int i = 0; i < 10; i++) @@ -54,8 +55,14 @@ public void TestAsync() } var ids = new List>(); - FileVersionManager.Instance.ComputeFileHashAsync(files, (file, id) => ids.Add(new Tuple(file, id))); - Thread.Sleep(200); + var tcs = new TaskCompletionSource(); + FileVersionManager.Instance.ComputeFileHashAsync(files, (file, id) => + { + ids.Add(new Tuple(file, id)); + if (ids.Count == files.Count) + tcs.SetResult(); + }); + await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); Assert.Equal(files.Count, ids.Count); diff --git a/sources/editor/Stride.GameStudio.Tests/XunitAttributes.cs b/sources/editor/Stride.GameStudio.Tests/XunitAttributes.cs new file mode 100644 index 0000000000..eb850f2fef --- /dev/null +++ b/sources/editor/Stride.GameStudio.Tests/XunitAttributes.cs @@ -0,0 +1,6 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. + +using Xunit; + +[assembly: CollectionBehavior(DisableTestParallelization = true)]