private CoreSessionHandle CreateSubject(out ReferenceCountedCoreSession referenceCounted)
        {
            var session = new Mock <ICoreSession>().Object;

            referenceCounted = new ReferenceCountedCoreSession(session);
            return(new CoreSessionHandle(referenceCounted));
        }
Пример #2
0
        public void constructor_should_initialize_instance()
        {
            var wrapped = new Mock <ICoreSession>().Object;

            var result = new ReferenceCountedCoreSession(wrapped);

            result.Wrapped.Should().BeSameAs(wrapped);
            result.IsDisposed().Should().BeFalse();
            result._ownsWrapped().Should().BeTrue();
            result._referenceCount().Should().Be(1);
        }
        public void constructor_with_reference_counted_should_intialize_instance()
        {
            var session          = new Mock <ICoreSession>().Object;
            var referenceCounted = new ReferenceCountedCoreSession(session);

            var result = new CoreSessionHandle(referenceCounted);

            result._ownsWrapped().Should().BeFalse();
            result.Wrapped.Should().BeSameAs(referenceCounted);
            referenceCounted._referenceCount().Should().Be(1);
        }
Пример #4
0
        public static int _referenceCount(this ReferenceCountedCoreSession obj)
        {
            var fieldInfo = typeof(ReferenceCountedCoreSession).GetField("_referenceCount", BindingFlags.NonPublic | BindingFlags.Instance);

            return((int)fieldInfo.GetValue(obj));
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CoreSessionHandle"/> class.
 /// </summary>
 /// <param name="wrapped">The wrapped.</param>
 internal CoreSessionHandle(ReferenceCountedCoreSession wrapped)
     : base(Ensure.IsNotNull(wrapped, nameof(wrapped)), ownsWrapped: false)
 {
     _wrapped = wrapped;
 }