PatternsCSharpProgramming/Patterns/BaseTests/007_ExpectingExceptions.cs

36 lines
852 B
C#
Raw Normal View History

2025-05-12 03:32:04 +03:00
/*
* Author: Nikolay Dvurechensky
* Site: https://www.dvurechensky.pro/
* Gmail: dvurechenskysoft@gmail.com
* Last Updated: 12 мая 2025 03:31:02
* Version: 1.0.7
*/
namespace Base.Tests;
2024-10-05 09:15:54 +03:00
[TestClass]
public class ExpectingExceptions
{
/// <summary>
/// Проверка метода на возврат исключения
/// </summary>
[ExpectedException(typeof(ArgumentNullException), "Exception was not throw")]
[TestMethod]
public void AssertMsTestExceptionTest()
{
var ms = new AssertMsTest();
ms.SayHello(null);
}
[TestMethod]
public void AssertMsTestReturnTest()
{
var name = "Hi! Nikolay";
var ms = new AssertMsTest();
var actual = ms.SayHello("Nikolay");
Assert.AreEqual(name, actual, $"name: {name} act: {actual}");
}
}