using UnitTestSharp; namespace Glass.UnitTests { public class ExceptionSiteTests : TestFixture { public class CtorTests : TestFixture { public void KeepsTheTargetAndPhase() { var control = new Control(); var site = new ExceptionSite(control, ExceptionPhase.Render); CheckEqual(control, site.Target); CheckEqual(ExceptionPhase.Render, site.Phase); } } public class EqualsTests : TestFixture { public void SameTargetAndPhase_AreEqual() { var control = new Control(); CheckTrue(new ExceptionSite(control, ExceptionPhase.Update) .Equals(new ExceptionSite(control, ExceptionPhase.Update))); } public void DifferentPhases_AreNotEqual() { var control = new Control(); CheckFalse(new ExceptionSite(control, ExceptionPhase.Update) .Equals(new ExceptionSite(control, ExceptionPhase.Layout))); } public void DifferentTargets_AreNotEqual() { CheckFalse(new ExceptionSite(new Control(), ExceptionPhase.Update) .Equals(new ExceptionSite(new Control(), ExceptionPhase.Update))); } public void TargetsThatMerelyCompareEqual_AreNotEqual() { string target = "target"; string equalTarget = new string(target.ToCharArray()); CheckFalse(new ExceptionSite(target, ExceptionPhase.Update) .Equals(new ExceptionSite(equalTarget, ExceptionPhase.Update))); } public void BoxedEqualSite_IsEqual() { var control = new Control(); object boxed = new ExceptionSite(control, ExceptionPhase.Input); CheckTrue(new ExceptionSite(control, ExceptionPhase.Input).Equals(boxed)); } public void SomethingOtherThanASite_IsNotEqual() { var control = new Control(); CheckFalse(new ExceptionSite(control, ExceptionPhase.Input).Equals(control)); } } public class GetHashCodeTests : TestFixture { public void EqualSites_HashTheSame() { var control = new Control(); CheckEqual(new ExceptionSite(control, ExceptionPhase.Render).GetHashCode(), new ExceptionSite(control, ExceptionPhase.Render).GetHashCode()); } } public class ToStringTests : TestFixture { public void NamesTheTargetAndThePhase() { CheckEqual("okButton Input", new ExceptionSite(new Control("okButton"), ExceptionPhase.Input).ToString()); } } } }