BaseTestClass
Base test class.
Propriedades
protected CancellationToken CancellationToken { get; }
value = baseTestClass.CancellationToken
Cancellation token for the test.
protected static bool IsLocalHost { get; }
value = BaseTestClass.IsLocalHost
Gets a value indicating whether the tests are running on localhost (not in CI environment).
public static string SecretsFile { get; set; }
value = BaseTestClass.SecretsFile
BaseTestClass.SecretsFile = value
Gets or sets the secrets file name. Can be set from AssemblyInitialize.
protected virtual bool SkipInCI { get; }
value = baseTestClass.SkipInCI
Skip all tests in this class when running in CI environment.
protected virtual string SkipInCIReason { get; }
value = baseTestClass.SkipInCIReason
Reason for skipping tests in CI environment.
public TestContext TestContext { get; set; }
value = baseTestClass.TestContext
baseTestClass.TestContext = value
TestContext
Métodos
protected static void AllItemsAreInstancesOfType(ICollection collection, Type expectedType, string message)
BaseTestClass.AllItemsAreInstancesOfType(collection, expectedType, message)
Asserts that all elements are instances of the specified type.
- collection
- Collection.
- expectedType
- Expected type.
- message
- Error message.
protected static void AllItemsAreNotNull(ICollection collection, string message)
BaseTestClass.AllItemsAreNotNull(collection, message)
Asserts that all elements are non-null.
- collection
- Collection.
- message
- Error message.
protected static void AllItemsAreUnique(ICollection collection, string message)
BaseTestClass.AllItemsAreUnique(collection, message)
Asserts that all elements are unique.
- collection
- Collection.
- message
- Error message.
protected static void AreEqual(float expected, float actual, float delta, string message)
BaseTestClass.AreEqual(expected, actual, delta, message)
Tests whether two floats are equal within the specified delta.
- expected
- Expected value.
- actual
- Actual value.
- delta
- Delta.
- message
- Error message.
protected static void AreEqual(double expected, double actual, double delta, string message)
BaseTestClass.AreEqual(expected, actual, delta, message)
Tests whether two doubles are equal within the specified delta.
- expected
- Expected value.
- actual
- Actual value.
- delta
- Delta.
- message
- Error message.
protected static void AreEqual(string expected, string actual, bool ignoreCase, string message)
BaseTestClass.AreEqual(expected, actual, ignoreCase, message)
Tests whether two strings are equal, ignoring case.
- expected
- Expected string.
- actual
- Actual string.
- ignoreCase
- Ignore case.
- message
- Error message.
protected static void AreEqual(ICollection expected, ICollection actual, string message)
BaseTestClass.AreEqual(expected, actual, message)
Asserts that two collections are equal.
- expected
- Expected collection.
- actual
- Actual collection.
- message
- Error message.
protected static void AreEqual<T>(T expected, T actual, string message)
BaseTestClass.AreEqual(expected, actual, message)
Tests whether two values are equal.
- expected
- Expected value.
- actual
- Actual value.
- message
- Error message.
protected static void AreEquivalent(ICollection expected, ICollection actual, string message)
BaseTestClass.AreEquivalent(expected, actual, message)
Asserts that two collections contain the same elements.
- expected
- Expected collection.
- actual
- Actual collection.
- message
- Error message.
protected static void AreNotEqual(float notExpected, float actual, float delta, string message)
BaseTestClass.AreNotEqual(notExpected, actual, delta, message)
Tests whether two floats are not equal within the specified delta.
- notExpected
- Not expected value.
- actual
- Actual value.
- delta
- Delta.
- message
- Error message.
protected static void AreNotEqual(double notExpected, double actual, double delta, string message)
BaseTestClass.AreNotEqual(notExpected, actual, delta, message)
Tests whether two doubles are not equal within the specified delta.
- notExpected
- Not expected value.
- actual
- Actual value.
- delta
- Delta.
- message
- Error message.
protected static void AreNotEqual(ICollection notExpected, ICollection actual, string message)
BaseTestClass.AreNotEqual(notExpected, actual, message)
Asserts that two collections are not equal.
- notExpected
- Not expected collection.
- actual
- Actual collection.
- message
- Error message.
protected static void AreNotEqual<T>(T notExpected, T actual, string message)
BaseTestClass.AreNotEqual(notExpected, actual, message)
Tests whether two values are not equal.
- notExpected
- Not expected value.
- actual
- Actual value.
- message
- Error message.
protected static void AreNotEquivalent(ICollection notExpected, ICollection actual, string message)
BaseTestClass.AreNotEquivalent(notExpected, actual, message)
Asserts that two collections do not contain the same elements.
- notExpected
- Not expected collection.
- actual
- Actual collection.
- message
- Error message.
protected static void AreNotSame(object notExpected, object actual, string message)
BaseTestClass.AreNotSame(notExpected, actual, message)
Tests whether two objects do not refer to the same instance.
- notExpected
- Not expected instance.
- actual
- Actual instance.
- message
- Error message.
protected static void AreSame(object expected, object actual, string message)
BaseTestClass.AreSame(expected, actual, message)
Tests whether two objects refer to the same instance.
- expected
- Expected instance.
- actual
- Actual instance.
- message
- Error message.
public void BaseTestInitialize()
baseTestClass.BaseTestInitialize()
Initializes the test.
protected static void Contains(ICollection collection, object element, string message)
BaseTestClass.Contains(collection, element, message)
Asserts that the collection contains the specified element.
- collection
- Collection.
- element
- Element expected to be present.
- message
- Error message.
protected static void Contains(string substring, string value, string message)
BaseTestClass.Contains(substring, value, message)
Tests whether a string contains a specified substring.
- substring
- Substring expected to be present.
- value
- The string to search.
- message
- Error message.
private static string Describe(string value)
result = BaseTestClass.Describe(value)
Renders a string for a failure message, so that a null reads differently from an empty string.
- value
- Value to render.
Retorna: Rendered value.
protected static void DoesNotContain(ICollection collection, object element, string message)
BaseTestClass.DoesNotContain(collection, element, message)
Asserts that the collection does not contain the specified element.
- collection
- Collection.
- element
- Element expected to be absent.
- message
- Error message.
protected static void DoesNotContain(string substring, string value, string message)
BaseTestClass.DoesNotContain(substring, value, message)
Tests whether the string does not contain the specified substring.
- substring
- Substring expected to be absent.
- value
- The string to search.
- message
- Error message.
protected static void DoesNotMatch(Regex pattern, string value, string message)
BaseTestClass.DoesNotMatch(pattern, value, message)
Tests whether a string does not match the specified regular expression.
- pattern
- Regex pattern.
- value
- The string to test.
- message
- Error message.
protected static void EndsWith(string substring, string value, string message)
BaseTestClass.EndsWith(substring, value, message)
Tests whether a string ends with the specified substring.
- substring
- Substring expected at the end.
- value
- The string to search.
- message
- Error message.
private static void EnsureArg(object arg, string name, string message)
BaseTestClass.EnsureArg(arg, name, message)
Fails the assertion when a required argument is null, naming it.
- arg
- Argument to check.
- name
- Name of the argument as the caller sees it.
- message
- Error message.
private static void EnsureRegexArgs(Regex pattern, string value, string message)
BaseTestClass.EnsureRegexArgs(pattern, value, message)
Fails the assertion when either argument of a regular expression check is null.
- pattern
- Pattern argument.
- value
- Value argument.
- message
- Error message.
private static void EnsureSubstringArgs(string substring, string value, string message)
BaseTestClass.EnsureSubstringArgs(substring, value, message)
Fails the assertion when either argument of a substring check is null.
- substring
- Substring argument.
- value
- Value argument.
- message
- Error message.
protected static string Env(string name)
result = BaseTestClass.Env(name)
Gets environment variable value.
- name
- Variable name.
Retorna: Value or null if not set.
protected static void Fail(string message)
BaseTestClass.Fail(message)
Fails the test without checking any conditions.
- message
- The message to include in the exception.
protected static string GetSecret(string key, bool encrypted)
result = BaseTestClass.GetSecret(key, encrypted)
Gets a secret value or marks test as inconclusive if not found.
- key
- Secret key (e.g., "BACKUP_AWS_REGION").
- encrypted
- When true, the resolved value is treated as a base64 ciphertext and decrypted. See Boolean).
Retorna: Secret value.
protected static void HasCount(int count, ICollection collection, string message)
BaseTestClass.HasCount(count, collection, message)
Asserts that the collection has the specified number of elements.
- count
- Expected number of elements.
- collection
- Collection to check.
- message
- Error message.
protected static void Inconclusive(string message)
BaseTestClass.Inconclusive(message)
Marks the test as inconclusive.
- message
- The message to include in the exception.
protected static void IsEmpty(string value, string message)
BaseTestClass.IsEmpty(value, message)
Tests whether the string is empty.
- value
- String value.
- message
- Error message.
protected static void IsEmpty(ICollection collection, string message)
BaseTestClass.IsEmpty(collection, message)
Tests whether the collection is empty.
- collection
- Collection.
- message
- Error message.
protected static void IsFalse(bool condition, string message)
BaseTestClass.IsFalse(condition, message)
Tests whether the specified condition is false.
- condition
- Condition.
- message
- Error message.
protected static void IsGreaterOrEqual<T>(T actual, T comparand, string message)
BaseTestClass.IsGreaterOrEqual(actual, comparand, message)
Tests whether the first value is greater than or equal to the second value.
- actual
- Actual value.
- comparand
- Value to compare against.
- message
- Error message.
protected static void IsGreater<T>(T actual, T comparand, string message)
BaseTestClass.IsGreater(actual, comparand, message)
Tests whether the first value is greater than the second value.
- actual
- Actual value.
- comparand
- Value to compare against.
- message
- Error message.
protected static void IsInRange<T>(T actual, T min, T max, string message)
BaseTestClass.IsInRange(actual, min, max, message)
Tests whether the value is within the specified range (inclusive).
- actual
- Actual value.
- min
- Minimum value (inclusive).
- max
- Maximum value (inclusive).
- message
- Error message.
protected static void IsInstanceOfType(object value, Type expectedType, string message)
BaseTestClass.IsInstanceOfType(value, expectedType, message)
Tests whether the specified object is an instance of the expected type.
- value
- Value.
- expectedType
- Expected type.
- message
- Error message.
protected static void IsInstanceOfType<T>(object value, string message)
BaseTestClass.IsInstanceOfType(value, message)
Tests whether the specified object is an instance of the expected type.
- value
- Value.
- message
- Error message.
protected static void IsLessOrEqual<T>(T actual, T comparand, string message)
BaseTestClass.IsLessOrEqual(actual, comparand, message)
Tests whether the first value is less than or equal to the second value.
- actual
- Actual value.
- comparand
- Value to compare against.
- message
- Error message.
protected static void IsLess<T>(T actual, T comparand, string message)
BaseTestClass.IsLess(actual, comparand, message)
Tests whether the first value is less than the second value.
- actual
- Actual value.
- comparand
- Value to compare against.
- message
- Error message.
protected static void IsNegative(double value, string message)
BaseTestClass.IsNegative(value, message)
Tests whether the value is negative (less than zero).
- value
- Value to check.
- message
- Error message.
protected static void IsNegative(long value, string message)
BaseTestClass.IsNegative(value, message)
Tests whether the value is negative (less than zero).
- value
- Value to check.
- message
- Error message.
protected static void IsNegative(int value, string message)
BaseTestClass.IsNegative(value, message)
Tests whether the value is negative (less than zero).
- value
- Value to check.
- message
- Error message.
protected static void IsNegative(decimal value, string message)
BaseTestClass.IsNegative(value, message)
Tests whether the value is negative (less than zero).
- value
- Value to check.
- message
- Error message.
protected static void IsNotEmpty(ICollection collection, string message)
BaseTestClass.IsNotEmpty(collection, message)
Tests whether the collection is not empty.
- collection
- Collection.
- message
- Error message.
protected static void IsNotEmpty(string value, string message)
BaseTestClass.IsNotEmpty(value, message)
Tests whether the string is not empty.
- value
- String value.
- message
- Error message.
protected static void IsNotInRange<T>(T actual, T min, T max, string message)
BaseTestClass.IsNotInRange(actual, min, max, message)
Tests whether the value is outside the specified range.
- actual
- Actual value.
- min
- Minimum value.
- max
- Maximum value.
- message
- Error message.
protected static void IsNotInstanceOfType(object value, Type wrongType, string message)
BaseTestClass.IsNotInstanceOfType(value, wrongType, message)
Tests whether the specified object is not an instance of the expected type.
- value
- Value.
- wrongType
- Wrong type.
- message
- Error message.
protected static void IsNotInstanceOfType<T>(object value, string message)
BaseTestClass.IsNotInstanceOfType(value, message)
Tests whether the specified object is not an instance of the expected type.
- value
- Value.
- message
- Error message.
protected static void IsNotNull(object value, string message)
BaseTestClass.IsNotNull(value, message)
Tests whether the specified value is not null.
- value
- Value.
- message
- Error message.
protected static void IsNotNullOrEmpty(string value, string message)
BaseTestClass.IsNotNullOrEmpty(value, message)
Tests whether the string is not null or empty.
- value
- String value.
- message
- Error message.
protected static void IsNotNullOrWhiteSpace(string value, string message)
BaseTestClass.IsNotNullOrWhiteSpace(value, message)
Tests whether the string is not null or whitespace.
- value
- String value.
- message
- Error message.
protected static void IsNotSubsetOf(ICollection subset, ICollection superset, string message)
BaseTestClass.IsNotSubsetOf(subset, superset, message)
Asserts that one collection is not a subset of another.
- subset
- Subset.
- superset
- Superset.
- message
- Error message.
protected static void IsNotZero(long value, string message)
BaseTestClass.IsNotZero(value, message)
Tests whether the value is not zero.
- value
- Value to check.
- message
- Error message.
protected static void IsNotZero(double value, string message)
BaseTestClass.IsNotZero(value, message)
Tests whether the value is not zero.
- value
- Value to check.
- message
- Error message.
protected static void IsNotZero(decimal value, string message)
BaseTestClass.IsNotZero(value, message)
Tests whether the value is not zero.
- value
- Value to check.
- message
- Error message.
protected static void IsNotZero(int value, string message)
BaseTestClass.IsNotZero(value, message)
Tests whether the value is not zero.
- value
- Value to check.
- message
- Error message.
protected static void IsNull(object value, string message)
BaseTestClass.IsNull(value, message)
Tests whether the specified value is null.
- value
- Value.
- message
- Error message.
protected static void IsNullOrEmpty(string value, string message)
BaseTestClass.IsNullOrEmpty(value, message)
Tests whether the string is null or empty.
- value
- String value.
- message
- Error message.
protected static void IsNullOrWhiteSpace(string value, string message)
BaseTestClass.IsNullOrWhiteSpace(value, message)
Tests whether the string is null or whitespace.
- value
- String value.
- message
- Error message.
protected static void IsPositive(decimal value, string message)
BaseTestClass.IsPositive(value, message)
Tests whether the value is positive (greater than zero).
- value
- Value to check.
- message
- Error message.
protected static void IsPositive(int value, string message)
BaseTestClass.IsPositive(value, message)
Tests whether the value is positive (greater than zero).
- value
- Value to check.
- message
- Error message.
protected static void IsPositive(long value, string message)
BaseTestClass.IsPositive(value, message)
Tests whether the value is positive (greater than zero).
- value
- Value to check.
- message
- Error message.
protected static void IsPositive(double value, string message)
BaseTestClass.IsPositive(value, message)
Tests whether the value is positive (greater than zero).
- value
- Value to check.
- message
- Error message.
protected static void IsSubsetOf(ICollection subset, ICollection superset, string message)
BaseTestClass.IsSubsetOf(subset, superset, message)
Asserts that one collection is a subset of another.
- subset
- Subset.
- superset
- Superset.
- message
- Error message.
protected static void IsTrue(bool condition, string message)
BaseTestClass.IsTrue(condition, message)
Tests whether the specified condition is true.
- condition
- Condition.
- message
- Error message.
protected static void IsZero(int value, string message)
BaseTestClass.IsZero(value, message)
Tests whether the value is zero.
- value
- Value to check.
- message
- Error message.
protected static void IsZero(long value, string message)
BaseTestClass.IsZero(value, message)
Tests whether the value is zero.
- value
- Value to check.
- message
- Error message.
protected static void IsZero(double value, string message)
BaseTestClass.IsZero(value, message)
Tests whether the value is zero.
- value
- Value to check.
- message
- Error message.
protected static void IsZero(decimal value, string message)
BaseTestClass.IsZero(value, message)
Tests whether the value is zero.
- value
- Value to check.
- message
- Error message.
protected static void MatchesRegex(Regex pattern, string value, string message)
BaseTestClass.MatchesRegex(pattern, value, message)
Tests whether a string matches the specified regular expression.
- pattern
- Regex pattern.
- value
- The string to match.
- message
- Error message.
protected static void StartsWith(string substring, string value, string message)
BaseTestClass.StartsWith(substring, value, message)
Tests whether a string starts with the specified substring.
- substring
- Substring expected at the beginning.
- value
- The string to search.
- message
- Error message.
protected static Task<T> ThrowsAsync<T>(Func<Task> action, string message)
result = BaseTestClass.ThrowsAsync(action, message)
Tests whether the code specified by delegate action throws exception of type (or derived).
- action
- Delegate to async code to be tested and which is expected to throw exception.
- message
- The message to include in the exception when action does not throw.
Retorna: The exception that was thrown.
protected static Task<T> ThrowsExactlyAsync<T>(Func<Task> action, string message)
result = BaseTestClass.ThrowsExactlyAsync(action, message)
Tests whether the code specified by delegate action throws exact given exception of type .
- action
- Delegate to async code to be tested and which is expected to throw exception.
- message
- The message to include in the exception when action does not throw.
Retorna: The exception that was thrown.
protected static T ThrowsExactly<T>(Action action, string message)
result = BaseTestClass.ThrowsExactly(action, message)
Tests whether the code specified by delegate action throws exact given exception of type .
- action
- Delegate to code to be tested and which is expected to throw exception.
- message
- The message to include in the exception when action does not throw.
Retorna: The exception that was thrown.
protected static T Throws<T>(Action action, string message)
result = BaseTestClass.Throws(action, message)
Tests whether the code specified by delegate action throws exception of type (or derived).
- action
- Delegate to code to be tested and which is expected to throw exception.
- message
- The message to include in the exception when action does not throw.
Retorna: The exception that was thrown.
protected static string TryGetSecret(string key, bool encrypted)
result = BaseTestClass.TryGetSecret(key, encrypted)
Tries to get a secret value from environment variable or JSON secrets file. Same key is used for both ENV and JSON lookup.
- key
- Secret key (e.g., "BACKUP_AWS_REGION").
- encrypted
- When true, the resolved value is treated as a base64 ciphertext and decrypted via the same SecureString primitive path used by SettingsStorage. Default false returns the raw value.
Retorna: Secret value or null if not found.