mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
Revert filescoped (#2227)
* Revert "Add git blame entry (#2226)" This reverts commit239286737d
. * Revert "Turn on file scoped namespaces (#2225)" This reverts commit34fb4cca2a
.
This commit is contained in:
@ -1,42 +1,43 @@
|
||||
using System.Reflection;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Bit.Test.Common.AutoFixture.Attributes;
|
||||
|
||||
/// <summary>
|
||||
/// Used for collecting data from environment useful for when we want to test an integration with another service and
|
||||
/// it might require an api key or other piece of sensitive data that we don't want slipping into the wrong hands.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// It probably should be refactored to support fixtures and other customization so it can more easily be used in conjunction
|
||||
/// with more parameters. Currently it attempt to match environment variable names to values of the parameter type in that positions.
|
||||
/// It will start from the first parameter and go for each supplied name.
|
||||
/// </remarks>
|
||||
public class EnvironmentDataAttribute : DataAttribute
|
||||
namespace Bit.Test.Common.AutoFixture.Attributes
|
||||
{
|
||||
private readonly string[] _environmentVariableNames;
|
||||
|
||||
public EnvironmentDataAttribute(params string[] environmentVariableNames)
|
||||
/// <summary>
|
||||
/// Used for collecting data from environment useful for when we want to test an integration with another service and
|
||||
/// it might require an api key or other piece of sensitive data that we don't want slipping into the wrong hands.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// It probably should be refactored to support fixtures and other customization so it can more easily be used in conjunction
|
||||
/// with more parameters. Currently it attempt to match environment variable names to values of the parameter type in that positions.
|
||||
/// It will start from the first parameter and go for each supplied name.
|
||||
/// </remarks>
|
||||
public class EnvironmentDataAttribute : DataAttribute
|
||||
{
|
||||
_environmentVariableNames = environmentVariableNames;
|
||||
}
|
||||
private readonly string[] _environmentVariableNames;
|
||||
|
||||
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
|
||||
{
|
||||
var methodParameters = testMethod.GetParameters();
|
||||
|
||||
if (methodParameters.Length < _environmentVariableNames.Length)
|
||||
public EnvironmentDataAttribute(params string[] environmentVariableNames)
|
||||
{
|
||||
throw new ArgumentException($"The target test method only has {methodParameters.Length} arguments but you supplied {_environmentVariableNames.Length}");
|
||||
_environmentVariableNames = environmentVariableNames;
|
||||
}
|
||||
|
||||
var values = new object[_environmentVariableNames.Length];
|
||||
|
||||
for (var i = 0; i < _environmentVariableNames.Length; i++)
|
||||
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
|
||||
{
|
||||
values[i] = Convert.ChangeType(Environment.GetEnvironmentVariable(_environmentVariableNames[i]), methodParameters[i].ParameterType);
|
||||
}
|
||||
var methodParameters = testMethod.GetParameters();
|
||||
|
||||
return new[] { values };
|
||||
if (methodParameters.Length < _environmentVariableNames.Length)
|
||||
{
|
||||
throw new ArgumentException($"The target test method only has {methodParameters.Length} arguments but you supplied {_environmentVariableNames.Length}");
|
||||
}
|
||||
|
||||
var values = new object[_environmentVariableNames.Length];
|
||||
|
||||
for (var i = 0; i < _environmentVariableNames.Length; i++)
|
||||
{
|
||||
values[i] = Convert.ChangeType(Environment.GetEnvironmentVariable(_environmentVariableNames[i]), methodParameters[i].ParameterType);
|
||||
}
|
||||
|
||||
return new[] { values };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user