Ejemplo n.º 1
0
        public void When__ExternalLamba_WithCapture()
        {
            Func <int, string> delegate1 = CreateWithCapture();
            Func <int, string> delegate2 = CreateWithCapture();

            var sut = new DelegateConditionalWeakTable <object>();

            var value1 = sut.GetValue(delegate1, _ => new object());
            var value2 = sut.GetValue(delegate2, _ => new object());

            Assert.AreNotSame(value1, value2);
        }
Ejemplo n.º 2
0
        public void When__Lamba()
        {
            Func <int, string> delegate1 = i => i.ToString();
            Func <int, string> delegate2 = i => i.ToString();

            var sut = new DelegateConditionalWeakTable <object>();

            var value1 = sut.GetValue(delegate1, _ => new object());
            var value2 = sut.GetValue(delegate2, _ => new object());

            Assert.AreNotSame(value1, value2);             // That sucks
        }
Ejemplo n.º 3
0
        public void When__Method()
        {
            Func <int, string> delegate1 = Method;
            Func <int, string> delegate2 = Method;

            var sut = new DelegateConditionalWeakTable <object>();

            var value1 = sut.GetValue(delegate1, _ => new object());
            var value2 = sut.GetValue(delegate2, _ => new object());

            Assert.AreSame(value1, value2);
        }
Ejemplo n.º 4
0
        public void When__Lamba_WithCapture()
        {
            var a = new Random().Next();

            Func <int, string> delegate1 = i => a.ToString();
            Func <int, string> delegate2 = i => a.ToString();

            var sut = new DelegateConditionalWeakTable <object>();

            var value1 = sut.GetValue(delegate1, _ => new object());
            var value2 = sut.GetValue(delegate2, _ => new object());

            Assert.AreNotSame(value1, value2);
        }