Код: Выделить всё
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace PdbLib
{
public static class AssertExtensions
{
public static void AssertVec3Equal(this Assert assert, Vec3 expected, Vec3 actual, double tolerance, string message = "")
{
Assert.IsTrue(expected.DistanceTo(actual) tolerance, message);
}
public static void AssertVec3Equal2(this Assert assert, Vec3 expected, Vec3 actual, double tolerance, string message = "")
{
if (Math.Abs(expected.X - actual.X) >= tolerance)
{
throw new AssertFailedException($"{message} X-component is incorrect. Expected: {expected.X}, Actual: {actual.X}");
}
if (Math.Abs(expected.Y - actual.Y) >= tolerance)
{
throw new AssertFailedException($"{message} Y-component is incorrect. Expected: {expected.Y}, Actual: {actual.Y}");
}
if (Math.Abs(expected.Z - actual.Z) >= tolerance)
{
throw new AssertFailedException($"{message} Z-component is incorrect. Expected: {expected.Z}, Actual: {actual.Z}");
}
}
}
}
Затем я добавил «unit_test_library» "Библиотека как ссылка на реальные проекты модульного тестирования.
Однако эти проекты не находят эти функции как члены класса Assert. p>
В чем проблема?
Я использую:
- Visual Studio 2017
- .NET Framework 4.7.2
Подробнее здесь: https://stackoverflow.com/questions/791 ... on-methods
Мобильная версия