PatternsCSharpProgramming/Patterns/BaseTests/006_StringAssetMethods.cs
Dvurechensky 3a28caed27 1.0
Main
2024-10-05 09:15:54 +03:00

45 lines
1.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Text.RegularExpressions;
namespace Base.Tests;
[TestClass]
public class StringAssetMethods
{
/// <summary>
/// Проверка подстроки в строке
/// </summary>
[TestMethod]
public void StringContainsTest()
{
StringAssert.Contains("Assert samples", "sam");
}
/// <summary>
/// ПРоверка с использованием регулярного выражения
/// </summary>
[TestMethod]
public void StringMathesTest()
{
// проверяет наличие трёх цифр подряд
StringAssert.Matches("123", new Regex(@"\d{3}"));
}
/// <summary>
/// Проверка начала строки на соответствие условию
/// </summary>
[TestMethod]
public void StringStartsWithTest()
{
StringAssert.StartsWith("Hello London", "H");
}
/// <summary>
/// Проверка конца строки на соответствие условию
/// </summary>
[TestMethod]
public void StringEndWithTest()
{
StringAssert.EndsWith("Hello Moscow", "w");
}
}