コード例 #1
0
        public void ShouldConstructTheObjectWithTheFactoryDelegate()
        {
            bool delegateCalled = false;

            FakeClass.ClearConstructorCount();

            RouteMethod result = this.adapter.CreateMethod(
                () =>
            {
                delegateCalled = true;
                return(new FakeClass());
            },
                typeof(FakeClass).GetMethod(nameof(FakeClass.MyMethod)));

            Assert.That(delegateCalled, Is.False);
            Assert.That(FakeClass.ConstructorCount.Value, Is.EqualTo(0));
            result(null);
            Assert.That(delegateCalled, Is.True);
            Assert.That(FakeClass.ConstructorCount.Value, Is.EqualTo(1));
        }