public void ThrowArgumentNullException_WhenNameArgumentIsNull()
 {
     // Act & Assert.
     Ensure.ArgumentNullExceptionIsThrown(() =>
     {
         PortableLazy<object> lazy = new PortableLazy<object>(null);
     }, "valueFactory");
 }
 public void ThrowArgumentNullException_WhenNameArgumentIsNull()
 {
     // Act & Assert.
     Ensure.ArgumentNullExceptionIsThrown(() =>
     {
         PortableLazy <object> lazy = new PortableLazy <object>(null);
     }, "valueFactory");
 }
        public void InvokeOnlyOnceValueFactory_WhenValueIsCalled()
        {
            // Arrange.
            int valueFactoryCallCount = 0;
            object value = new object();

            PortableLazy<object> lazy =
                new PortableLazy<object>(
                () => 
                {
                    valueFactoryCallCount++; 
                    return value; 
                });

            // Act & Assert.
            for (int i = 0; i < 5; i++)
            {
                Assert.AreSame(value, lazy.Value);
            }

            Assert.AreEqual(1, valueFactoryCallCount);
        }
        public void InvokeOnlyOnceValueFactory_WhenValueIsCalled()
        {
            // Arrange.
            int    valueFactoryCallCount = 0;
            object value = new object();

            PortableLazy <object> lazy =
                new PortableLazy <object>(
                    () =>
            {
                valueFactoryCallCount++;
                return(value);
            });

            // Act & Assert.
            for (int i = 0; i < 5; i++)
            {
                Assert.AreSame(value, lazy.Value);
            }

            Assert.AreEqual(1, valueFactoryCallCount);
        }
Ejemplo n.º 5
0
 static StringNotNullOrWhiteSpaceValidationPredicate()
 {
     lazyInstance = new PortableLazy <StringNotNullOrWhiteSpaceValidationPredicate>(() => new StringNotNullOrWhiteSpaceValidationPredicate());
 }
 static FloatNotInfinityValidationPredicate()
 {
     lazyInstance = new PortableLazy <FloatNotInfinityValidationPredicate>(() => new FloatNotInfinityValidationPredicate());
 }
Ejemplo n.º 7
0
 static MemberOfEnumValidationPredicate()
 {
     lazyInstance = new PortableLazy <MemberOfEnumValidationPredicate <TEnum> >(() => new MemberOfEnumValidationPredicate <TEnum>());
 }
Ejemplo n.º 8
0
 static DoubleInfinityValidationPredicate()
 {
     lazyInstance = new PortableLazy <DoubleInfinityValidationPredicate>(() => new DoubleInfinityValidationPredicate());
 }
Ejemplo n.º 9
0
 static DoubleNotNaNValidationPredicate()
 {
     lazyInstance = new PortableLazy <DoubleNotNaNValidationPredicate>(() => new DoubleNotNaNValidationPredicate());
 }
Ejemplo n.º 10
0
 static NotNullValidationPredicate()
 {
     lazyInstance = new PortableLazy <NotNullValidationPredicate <T> >(() => new NotNullValidationPredicate <T>());
 }
Ejemplo n.º 11
0
 static StringEmptyValidationPredicate()
 {
     lazyInstance = new PortableLazy <StringEmptyValidationPredicate>(() => new StringEmptyValidationPredicate());
 }
 static FalseValidationPredicate()
 {
     lazyInstance = new PortableLazy <FalseValidationPredicate>(() => new FalseValidationPredicate());
 }
Ejemplo n.º 13
0
 static TrueValidationPredicate()
 {
     lazyInstance = new PortableLazy <TrueValidationPredicate>(() => new TrueValidationPredicate());
 }
Ejemplo n.º 14
0
 static GuidEmptyValidationPredicate()
 {
     lazyInstance = new PortableLazy <GuidEmptyValidationPredicate>(() => new GuidEmptyValidationPredicate());
 }
Ejemplo n.º 15
0
 static EnumerableNotNullOrEmptyValidationPredicate()
 {
     lazyInstance = new PortableLazy <EnumerableNotNullOrEmptyValidationPredicate <T> >(() => new EnumerableNotNullOrEmptyValidationPredicate <T>());
 }