public void BadArgsInGetValue()
        {
            LazyContainerEntry <Object> entry = new LazyContainerEntry <Object>(_ => new Object());

            Assert.Throws <ArgumentNullException>(() => entry.GetValue(null));
            Assert.Throws <ArgumentNullException>(() => ((IContainerEntry)entry).GetValue(null));
        }
 public void TestValueCreation()
 {
     IServiceContainer container = _repository.Stub<IServiceContainer>();
     CreateFunc<String> initializer;
     using (_repository.Record())
     {
         initializer = _repository.StrictMock<CreateFunc<String>>();
         Expect.Call(initializer(container)).Return("IDDQD").Repeat.Once();
     }
     using (_repository.Playback())
     {
         LazyContainerEntry<String> entry = new LazyContainerEntry<String>(initializer);
         Assert.AreEqual("IDDQD", entry.GetValue(container));
         Assert.AreEqual("IDDQD", entry.GetValue(container));
     }
 }
Ejemplo n.º 3
0
        public void TestValueCreation()
        {
            IServiceContainer   container = _repository.Stub <IServiceContainer>();
            CreateFunc <String> initializer;

            using (_repository.Record())
            {
                initializer = _repository.StrictMock <CreateFunc <String> >();
                Expect.Call(initializer(container)).Return("IDDQD").Repeat.Once();
            }
            using (_repository.Playback())
            {
                LazyContainerEntry <String> entry = new LazyContainerEntry <String>(initializer);
                Assert.AreEqual("IDDQD", entry.GetValue(container));
                Assert.AreEqual("IDDQD", entry.GetValue(container));
            }
        }
 public void BadArgsInGetValue()
 {
     LazyContainerEntry<Object> entry = new LazyContainerEntry<Object>(_ => new Object());
     Assert.Throws<ArgumentNullException>(() => entry.GetValue(null));
     Assert.Throws<ArgumentNullException>(() => ((IContainerEntry) entry).GetValue(null));
 }