Inheritance: DescriptorBase
示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NetworkSession"/> class.
        /// </summary>
        public NetworkSession()
        {
            _isActive = false;

            _receiveDescriptor = new ReceiveDescriptor(this);
            _sendDescriptor    = new SendDescriptor(this);
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NetworkSession"/> class.
        /// </summary>
        public NetworkSession()
        {
            this.isActive = false;

            this.receiveDescriptor = new ReceiveDescriptor(this);
            this.sendDescriptor = new SendDescriptor(this);
        }
示例#3
0
        public void StartReceive_Should_Throw_If_DataArrived_Has_No_Subscribers()
        {
            var descriptor = new ReceiveDescriptor(Mock.Of <IDescriptorContainer>());

            descriptor
            .Invoking(d => d.StartReceive())
            .ShouldThrow <InvalidOperationException>()
            .WithMessage(CommonStrings.ReceiveEventHasNoSubscribers);
        }
        public void StartReceive_Should_Throw_If_DataArrived_Has_No_Subscribers()
        {
            var descriptor = new ReceiveDescriptor(Mock.Of<IDescriptorContainer>());

            descriptor
                .Invoking(d => d.StartReceive())
                .ShouldThrow<InvalidOperationException>()
                .WithMessage(CommonStrings.ReceiveEventHasNoSubscribers);
        }
        public void DataArrived_Should_Throw_When_Delegate_Already_Bound()
        {
            var descriptor = new ReceiveDescriptor(Mock.Of<IDescriptorContainer>());
            descriptor.DataArrived += (o, e) => { };

            descriptor
                .Invoking(d => d.DataArrived += (o, e) => { })
                .ShouldThrow<InvalidOperationException>()
                .WithMessage(CommonStrings.EventMustHaveOnlyOneSubscriber);
        }
示例#6
0
        public void DataArrived_Should_Throw_When_Delegate_Already_Bound()
        {
            var descriptor = new ReceiveDescriptor(Mock.Of <IDescriptorContainer>());

            descriptor.DataArrived += (o, e) => { };

            descriptor
            .Invoking(d => d.DataArrived += (o, e) => { })
            .ShouldThrow <InvalidOperationException>()
            .WithMessage(CommonStrings.EventMustHaveOnlyOneSubscriber);
        }
        public void StartReceive_Should_Check_Container_IsActive()
        {
            var container = new Mock<IDescriptorContainer>();
            container.SetupGet(c => c.IsActive).Returns(false);

            var descriptor = new ReceiveDescriptor(container.Object);
            descriptor.DataArrived += (sender, args) => { };
            descriptor.StartReceive();

            container.Verify(c => c.IsActive, Times.Once());
        }
示例#8
0
        public void StartReceive_Should_Check_Container_IsActive()
        {
            var container = new Mock <IDescriptorContainer>();

            container.SetupGet(c => c.IsActive).Returns(false);

            var descriptor = new ReceiveDescriptor(container.Object);

            descriptor.DataArrived += (sender, args) => { };
            descriptor.StartReceive();

            container.Verify(c => c.IsActive, Times.Once());
        }