mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
Turn on file scoped namespaces (#2225)
This commit is contained in:
@ -1,45 +1,44 @@
|
||||
namespace Bit.Test.Common.Helpers
|
||||
namespace Bit.Test.Common.Helpers;
|
||||
|
||||
public static class TestCaseHelper
|
||||
{
|
||||
public static class TestCaseHelper
|
||||
public static IEnumerable<IEnumerable<T>> GetCombinations<T>(params T[] items)
|
||||
{
|
||||
public static IEnumerable<IEnumerable<T>> GetCombinations<T>(params T[] items)
|
||||
var count = Math.Pow(2, items.Length);
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var count = Math.Pow(2, items.Length);
|
||||
for (var i = 0; i < count; i++)
|
||||
var str = Convert.ToString(i, 2).PadLeft(items.Length, '0');
|
||||
List<T> combination = new();
|
||||
for (var j = 0; j < str.Length; j++)
|
||||
{
|
||||
var str = Convert.ToString(i, 2).PadLeft(items.Length, '0');
|
||||
List<T> combination = new();
|
||||
for (var j = 0; j < str.Length; j++)
|
||||
if (str[j] == '1')
|
||||
{
|
||||
if (str[j] == '1')
|
||||
{
|
||||
combination.Add(items[j]);
|
||||
}
|
||||
combination.Add(items[j]);
|
||||
}
|
||||
yield return combination;
|
||||
}
|
||||
yield return combination;
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<IEnumerable<object>> GetCombinationsOfMultipleLists(params IEnumerable<object>[] optionLists)
|
||||
{
|
||||
if (!optionLists.Any())
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
public static IEnumerable<IEnumerable<object>> GetCombinationsOfMultipleLists(params IEnumerable<object>[] optionLists)
|
||||
foreach (var item in optionLists.First())
|
||||
{
|
||||
if (!optionLists.Any())
|
||||
var itemArray = new[] { item };
|
||||
|
||||
if (optionLists.Length == 1)
|
||||
{
|
||||
yield break;
|
||||
yield return itemArray;
|
||||
}
|
||||
|
||||
foreach (var item in optionLists.First())
|
||||
foreach (var nextCombination in GetCombinationsOfMultipleLists(optionLists.Skip(1).ToArray()))
|
||||
{
|
||||
var itemArray = new[] { item };
|
||||
|
||||
if (optionLists.Length == 1)
|
||||
{
|
||||
yield return itemArray;
|
||||
}
|
||||
|
||||
foreach (var nextCombination in GetCombinationsOfMultipleLists(optionLists.Skip(1).ToArray()))
|
||||
{
|
||||
yield return itemArray.Concat(nextCombination);
|
||||
}
|
||||
yield return itemArray.Concat(nextCombination);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user