using System; using Chernobyl.Readiness; using NUnit.Framework; namespace Chernobyl.Values { [TestFixture, Description("Tests for the NotReady type.")] public class NotNullTests : ValueTests, string> { //---------------------------------------------------------------------- // NotNull(IValue) //---------------------------------------------------------------------- [Test, Description("Ensures NotNull(IValue) throws an ArgumentNullException " + "when it is given a null argument.")] public void ConstructorIValueArgumentNullException() { // ReSharper disable ObjectCreationAsStatement Assert.Throws(() => new NotNull(null)); // ReSharper restore ObjectCreationAsStatement } //---------------------------------------------------------------------- // Change Tests //---------------------------------------------------------------------- [Test, Description("A test to ensure that setting the internal value of " + "IValue to the value it is already set at raises the " + "IValue.Provide event if the IValue is not ready. " + "Override this test if it is not applicable.")] [Ignore("NotNull is only ready when the value is not null.")] public override void ProvideRaisedWhenValueIsNotChangedButIsMadeReady() {} //---------------------------------------------------------------------- // Utility //---------------------------------------------------------------------- protected override ValueTests, string>.Wrapper CreateValue() { return new Wrapper(); } protected new class Wrapper : ValueTests, string>.Wrapper { public Wrapper() : base(null, "hola", "hello" ) { TestInstance = new NotNull(_container); } public override void MakeReady() { _container.Value = "hola"; } public override void ChangeValue() { _container.Value = FinalValue; } public override void FakeChangeValue() { _container.Value = _container.Value; } readonly DynamicContainer _container = new DynamicContainer(); } } }