Пример #1
0
        public void Dispose_should_set_disposed_flag()
        {
            var pool        = new Mock <IServerSessionPool>().Object;
            var mockWrapped = new Mock <IServerSession>();
            var subject     = new ServerSessionPool.ReleaseOnDisposeServerSession(mockWrapped.Object, pool);

            subject.Dispose();

            subject._disposed().Should().BeTrue();
        }
Пример #2
0
        public void Dispose_should_call_ReleaseSession()
        {
            var mockPool    = new Mock <IServerSessionPool>();
            var mockWrapped = new Mock <IServerSession>();
            var subject     = new ServerSessionPool.ReleaseOnDisposeServerSession(mockWrapped.Object, mockPool.Object);

            subject.Dispose();

            mockPool.Verify(m => m.ReleaseSession(mockWrapped.Object), Times.Once);
            mockWrapped.Verify(m => m.Dispose(), Times.Never);
        }
Пример #3
0
        public void constructor_should_initialize_instance()
        {
            var pool    = new Mock <IServerSessionPool>().Object;
            var wrapped = new Mock <IServerSession>().Object;

            var result = new ServerSessionPool.ReleaseOnDisposeServerSession(wrapped, pool);

            result.Wrapped.Should().BeSameAs(wrapped);
            result._pool().Should().BeSameAs(pool);
            result._disposed().Should().BeFalse();
            result._ownsWrapped().Should().BeFalse();
        }
Пример #4
0
        public static IServerSessionPool _pool(this ServerSessionPool.ReleaseOnDisposeServerSession obj)
        {
            var fieldInfo = typeof(ServerSessionPool.ReleaseOnDisposeServerSession).GetField("_pool", BindingFlags.NonPublic | BindingFlags.Instance);

            return((IServerSessionPool)fieldInfo.GetValue(obj));
        }