mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
add tests for loading unique metadata method
This commit is contained in:
parent
a07252cc04
commit
c7e77e3912
3 changed files with 92 additions and 18 deletions
|
|
@ -59,7 +59,7 @@ namespace Flow.Launcher.Core.Plugin
|
|||
return uniqueList;
|
||||
}
|
||||
|
||||
private static (List<PluginMetadata>, List<PluginMetadata>) GetUniqueLatestPluginMetadata(List<PluginMetadata> allPluginMetadata)
|
||||
internal static (List<PluginMetadata>, List<PluginMetadata>) GetUniqueLatestPluginMetadata(List<PluginMetadata> allPluginMetadata)
|
||||
{
|
||||
var duplicate_list = new List<PluginMetadata>();
|
||||
var unique_list = new List<PluginMetadata>();
|
||||
|
|
|
|||
91
Flow.Launcher.Test/PluginLoadTest.cs
Normal file
91
Flow.Launcher.Test/PluginLoadTest.cs
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
using NUnit.Framework;
|
||||
using Flow.Launcher.Core.Plugin;
|
||||
using Flow.Launcher.Plugin;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Flow.Launcher.Test
|
||||
{
|
||||
[TestFixture]
|
||||
class PluginLoadTest
|
||||
{
|
||||
[Test]
|
||||
public void GivenDuplicatePluginMetadatasWhenLoadedThenShouldReturnOnlyUniqueList()
|
||||
{
|
||||
// Given
|
||||
var duplicateList = new List<PluginMetadata>
|
||||
{
|
||||
new PluginMetadata
|
||||
{
|
||||
ID = "CEA0TYUC6D3B4085823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
},
|
||||
new PluginMetadata
|
||||
{
|
||||
ID = "CEA0TYUC6D3B4085823D60DC76F28855",
|
||||
Version = "1.0.1"
|
||||
},
|
||||
new PluginMetadata
|
||||
{
|
||||
ID = "CEA0TYUC6D3B4085823D60DC76F28855",
|
||||
Version = "1.0.2"
|
||||
},
|
||||
new PluginMetadata
|
||||
{
|
||||
ID = "CEA0TYUC6D3B4085823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
},
|
||||
new PluginMetadata
|
||||
{
|
||||
ID = "CEA0TYUC6D3B4085823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
},
|
||||
new PluginMetadata
|
||||
{
|
||||
ID = "CEA0TYUC6D3B7855823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
},
|
||||
new PluginMetadata
|
||||
{
|
||||
ID = "CEA0TYUC6D3B7855823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
}
|
||||
};
|
||||
|
||||
// When
|
||||
(var unique, var duplicates) = PluginConfig.GetUniqueLatestPluginMetadata(duplicateList);
|
||||
|
||||
// Then
|
||||
Assert.True(unique.FirstOrDefault().ID == "CEA0TYUC6D3B4085823D60DC76F28855" && unique.FirstOrDefault().Version == "1.0.2");
|
||||
Assert.True(unique.Count() == 1);
|
||||
|
||||
Assert.True(duplicates.Where(x => x.Version != "1.0.2" && x.ID == "CEA0TYUC6D3B4085823D60DC76F28855").Count() == 6);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GivenDuplicatePluginMetadatasWithNoUniquePluginWhenLoadedThenShouldReturnEmptyList()
|
||||
{
|
||||
// Given
|
||||
var duplicateList = new List<PluginMetadata>
|
||||
{
|
||||
new PluginMetadata
|
||||
{
|
||||
ID = "CEA0TYUC6D3B7855823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
},
|
||||
new PluginMetadata
|
||||
{
|
||||
ID = "CEA0TYUC6D3B7855823D60DC76F28855",
|
||||
Version = "1.0.0"
|
||||
}
|
||||
};
|
||||
|
||||
// When
|
||||
(var unique, var duplicates) = PluginConfig.GetUniqueLatestPluginMetadata(duplicateList);
|
||||
|
||||
// Then
|
||||
Assert.True(unique.Count() == 0);
|
||||
Assert.True(duplicates.Count() == 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
using NUnit.Framework;
|
||||
using Flow.Launcher.Core.Plugin;
|
||||
using Flow.Launcher.Infrastructure.Exception;
|
||||
|
||||
namespace Flow.Launcher.Test.Plugins
|
||||
{
|
||||
|
||||
[TestFixture]
|
||||
public class PluginInitTest
|
||||
{
|
||||
[Test]
|
||||
public void PublicAPIIsNullTest()
|
||||
{
|
||||
//Assert.Throws(typeof(Flow.LauncherFatalException), () => PluginManager.Initialize(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue