Ejemplo n.º 1
0
        public void MockGenericStaticKeyed_with_string_should_be_lazy()
        {
            MockGenericStaticKeyed <string> .Factory = i => Guid.NewGuid().ToString("n");
            Assert.AreEqual(0, MockGenericStaticKeyed <string> .GetValueCount);
            var first = MockGenericStaticKeyed <string> .GetValue("test");

            Assert.AreNotEqual(null, first);
            Assert.AreEqual(1, MockGenericStaticKeyed <string> .GetValueCount);
            var second = MockGenericStaticKeyed <string> .GetValue("test");

            Assert.AreEqual(first, second);
            Assert.AreEqual(1, MockGenericStaticKeyed <string> .GetValueCount);
        }
Ejemplo n.º 2
0
        public void MockGenericStaticKeyed_with_int_should_be_lazy()
        {
            MockGenericStaticKeyed <int> .Factory = i => 123;
            Assert.AreEqual(0, MockGenericStaticKeyed <int> .GetValueCount);
            var first = MockGenericStaticKeyed <int> .GetValue(1);

            Assert.AreEqual(123, first);
            Assert.AreEqual(1, MockGenericStaticKeyed <int> .GetValueCount);
            var second = MockGenericStaticKeyed <int> .GetValue(1);

            Assert.AreEqual(first, second);
            Assert.AreEqual(1, MockGenericStaticKeyed <int> .GetValueCount);
        }