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);
        }
Esempio n. 5
0
 static StringNotNullOrWhiteSpaceValidationPredicate()
 {
     lazyInstance = new PortableLazy <StringNotNullOrWhiteSpaceValidationPredicate>(() => new StringNotNullOrWhiteSpaceValidationPredicate());
 }
 static FloatNotInfinityValidationPredicate()
 {
     lazyInstance = new PortableLazy <FloatNotInfinityValidationPredicate>(() => new FloatNotInfinityValidationPredicate());
 }
Esempio n. 7
0
 static MemberOfEnumValidationPredicate()
 {
     lazyInstance = new PortableLazy <MemberOfEnumValidationPredicate <TEnum> >(() => new MemberOfEnumValidationPredicate <TEnum>());
 }
Esempio n. 8
0
 static DoubleInfinityValidationPredicate()
 {
     lazyInstance = new PortableLazy <DoubleInfinityValidationPredicate>(() => new DoubleInfinityValidationPredicate());
 }
Esempio n. 9
0
 static DoubleNotNaNValidationPredicate()
 {
     lazyInstance = new PortableLazy <DoubleNotNaNValidationPredicate>(() => new DoubleNotNaNValidationPredicate());
 }
Esempio n. 10
0
 static NotNullValidationPredicate()
 {
     lazyInstance = new PortableLazy <NotNullValidationPredicate <T> >(() => new NotNullValidationPredicate <T>());
 }
Esempio n. 11
0
 static StringEmptyValidationPredicate()
 {
     lazyInstance = new PortableLazy <StringEmptyValidationPredicate>(() => new StringEmptyValidationPredicate());
 }
 static FalseValidationPredicate()
 {
     lazyInstance = new PortableLazy <FalseValidationPredicate>(() => new FalseValidationPredicate());
 }
Esempio n. 13
0
 static TrueValidationPredicate()
 {
     lazyInstance = new PortableLazy <TrueValidationPredicate>(() => new TrueValidationPredicate());
 }
Esempio n. 14
0
 static GuidEmptyValidationPredicate()
 {
     lazyInstance = new PortableLazy <GuidEmptyValidationPredicate>(() => new GuidEmptyValidationPredicate());
 }
Esempio n. 15
0
 static EnumerableNotNullOrEmptyValidationPredicate()
 {
     lazyInstance = new PortableLazy <EnumerableNotNullOrEmptyValidationPredicate <T> >(() => new EnumerableNotNullOrEmptyValidationPredicate <T>());
 }