using NSubstitute;
using NUnit.Framework;
using System;
using System.ComponentModel;
using System.Prig;
using Urasandesu.Prig.Framework;

namespace TraditionalMockingFrameworkSample
{
    [TestFixture]
    public class NSubstituteTest
    {
        [Test]
        public void ValueWithRandomAdded_should_hold_passed_value_plus_random_value()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var notifyingObject = new NotifyingObject();

                var mockNext = Substitute.For<IndirectionFunc<Random, int>>();
                mockNext(Arg.Any<Random>()).Returns(10);
                PRandom.Next().Body = mockNext;


                // Act
                notifyingObject.ValueWithRandomAdded = 32;
                var actual = notifyingObject.ValueWithRandomAdded;


                // Assert
                mockNext.Received(1)(Arg.Any<Random>());
                Assert.AreEqual(42, actual);
            }
        }
    }
}