public void TestClear_Initialized() { int messageId = Environment.TickCount; string methodName = Guid.NewGuid().ToString(); Action <ClientResponseContext, Exception, Boolean> completionCallback = (_0, _1, _2) => { }; var target = new ClientRequestContext(); target.RenewSessionId(); target.SetRequest(messageId, methodName, completionCallback); target.ArgumentsPacker.Pack(1); target.Clear(); Assert.That(target.ArgumentsPacker, Is.Not.Null); Assert.That(target.ArgumentsPacker.Position, Is.EqualTo(0)); Assert.That(target.BoundTransport, Is.Null); Assert.That(target.MessageId, Is.Null); Assert.That(target.MessageType, Is.EqualTo(MessageType.Response)); Assert.That(target.MethodName, Is.Null); Assert.That(target.NotificationCompletionCallback, Is.Null); Assert.That(target.RequestCompletionCallback, Is.Null); Assert.That(target.SendingBuffer.All(segment => segment.Array == null)); Assert.That(target.SessionId, Is.EqualTo(0)); Assert.That(target.SessionStartedAt, Is.EqualTo(default(DateTimeOffset))); }
/// <summary> /// Returns the request context to the pool. /// </summary> /// <param name="context">The context to the pool.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="context"/> is <c>null</c>. /// </exception> protected internal void ReturnRequestContext(ClientRequestContext context) { if (context == null) { throw new ArgumentNullException("context"); } Contract.EndContractBlock(); context.Clear(); context.UnboundTransport(); this.RequestContextPool.Return(context); }
public void TestClear_Initialized() { int messageId = Environment.TickCount; string methodName = Guid.NewGuid().ToString(); Action<ClientResponseContext, Exception, Boolean> completionCallback = ( _0, _1, _2 ) => { }; var target = new ClientRequestContext(); target.RenewSessionId(); target.SetRequest( messageId, methodName, completionCallback ); target.ArgumentsPacker.Pack( 1 ); target.Clear(); Assert.That( target.ArgumentsPacker, Is.Not.Null ); Assert.That( target.ArgumentsPacker.Position, Is.EqualTo( 0 ) ); Assert.That( target.BoundTransport, Is.Null ); Assert.That( target.MessageId, Is.Null ); Assert.That( target.MessageType, Is.EqualTo( MessageType.Response ) ); Assert.That( target.MethodName, Is.Null ); Assert.That( target.NotificationCompletionCallback, Is.Null ); Assert.That( target.RequestCompletionCallback, Is.Null ); Assert.That( target.SendingBuffer.All( segment => segment.Array == null ) ); Assert.That( target.SessionId, Is.EqualTo( 0 ) ); Assert.That( target.SessionStartedAt, Is.EqualTo( default( DateTimeOffset ) ) ); }
/// <summary> /// Returns the request context to the pool. /// </summary> /// <param name="context">The context to the pool.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="context"/> is <c>null</c>. /// </exception> protected internal void ReturnRequestContext( ClientRequestContext context ) { if ( context == null ) { throw new ArgumentNullException( "context" ); } Contract.EndContractBlock(); context.Clear(); context.UnboundTransport(); this.RequestContextPool.Return( context ); }