42. EditMode Tests の例 - テスト対象
42
using UnityEngine;
/// <summary>
/// 弾丸にまつわるドメインロジック
/// </summary>
public class Bullet
{
/// <summary>
/// 2つの<c>Vector3</c>が衝突したと判断できればtrueを返す
/// </summary>
public static bool IsHit(ref Vector3 a, ref Vector3 b)
{
// snip
}
// snip
}
43. 43
EditMode Tests の例 - テストメソッド
using NUnit.Framework;
using UnityEngine;
public class BulletTest
{
[Test]
public void IsHit_notHit()
{
}
}
44. 44
EditMode Tests の例 - Verify
using NUnit.Framework;
using UnityEngine;
public class BulletTest
{
[Test]
public void IsHit_notHit()
{
Assert.That(actual, Is.False);
}
}
45. 45
EditMode Tests の例 - Exercise
using NUnit.Framework;
using UnityEngine;
public class BulletTest
{
[Test]
public void IsHit_notHit()
{
var actual = Bullet.IsHit(ref a, ref b);
Assert.That(actual, Is.False);
}
}
46. 46
EditMode Tests の例 - Setup
using NUnit.Framework;
using UnityEngine;
public class BulletTest
{
[Test]
public void IsHit_notHit()
{
var a = new Vector3(100, 200, 300);
var b = new Vector3(100, 200, 3000);
var actual = Bullet.IsHit(ref a, ref b);
Assert.That(actual, Is.False);
}
}