public void Must_initialize_using_func_supplied_in_constructor() { var entity = new object(); var systemUnderTest = new LazyEntity<object>(() => entity); Assert.That(systemUnderTest.Value, Is.SameAs(entity)); }
public async void Must_throw_exception_if_caching_the_same_lazy_entity_more_than_once() { using (INonTransactionalCacheKeySession systemUnderTest = await SessionManager.Enroll()) { var lazyEntity = new LazyEntity<object>(() => new object()); systemUnderTest.LazyEntityWasCreated(lazyEntity, Guid.NewGuid()); Assert.Throws<SessionException>(() => systemUnderTest.LazyEntityWasCreated(lazyEntity, Guid.NewGuid()), "Cannot cache lazy entity more than once."); } }
public async void Must_add_lazy_entity_if_it_is_not_cached() { using (INonTransactionalCacheKeySession systemUnderTest = await SessionManager.Enroll()) { var lazyEntity = new LazyEntity<object>(() => new object()); Guid entityId = Guid.NewGuid(); systemUnderTest.LazyEntityWasCreated(lazyEntity, entityId); Assert.That(systemUnderTest.GetEntityId(lazyEntity), Is.EqualTo(entityId)); } }
public void Must_initialize_value_immediately() { var systemUnderTest = new LazyEntity<object>(new object()); Assert.That(systemUnderTest.IsValueCreated, Is.True); }