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); }
static StringNotNullOrWhiteSpaceValidationPredicate() { lazyInstance = new PortableLazy <StringNotNullOrWhiteSpaceValidationPredicate>(() => new StringNotNullOrWhiteSpaceValidationPredicate()); }
static FloatNotInfinityValidationPredicate() { lazyInstance = new PortableLazy <FloatNotInfinityValidationPredicate>(() => new FloatNotInfinityValidationPredicate()); }
static MemberOfEnumValidationPredicate() { lazyInstance = new PortableLazy <MemberOfEnumValidationPredicate <TEnum> >(() => new MemberOfEnumValidationPredicate <TEnum>()); }
static DoubleInfinityValidationPredicate() { lazyInstance = new PortableLazy <DoubleInfinityValidationPredicate>(() => new DoubleInfinityValidationPredicate()); }
static DoubleNotNaNValidationPredicate() { lazyInstance = new PortableLazy <DoubleNotNaNValidationPredicate>(() => new DoubleNotNaNValidationPredicate()); }
static NotNullValidationPredicate() { lazyInstance = new PortableLazy <NotNullValidationPredicate <T> >(() => new NotNullValidationPredicate <T>()); }
static StringEmptyValidationPredicate() { lazyInstance = new PortableLazy <StringEmptyValidationPredicate>(() => new StringEmptyValidationPredicate()); }
static FalseValidationPredicate() { lazyInstance = new PortableLazy <FalseValidationPredicate>(() => new FalseValidationPredicate()); }
static TrueValidationPredicate() { lazyInstance = new PortableLazy <TrueValidationPredicate>(() => new TrueValidationPredicate()); }
static GuidEmptyValidationPredicate() { lazyInstance = new PortableLazy <GuidEmptyValidationPredicate>(() => new GuidEmptyValidationPredicate()); }
static EnumerableNotNullOrEmptyValidationPredicate() { lazyInstance = new PortableLazy <EnumerableNotNullOrEmptyValidationPredicate <T> >(() => new EnumerableNotNullOrEmptyValidationPredicate <T>()); }