public void SendsWriteRequest() { TransferStub transfer = new TransferStub(new MemoryStream(new byte[5000])); transfer.SetState(new SendWriteRequest()); Assert.IsTrue(transfer.CommandWasSent(typeof(WriteRequest))); }
public void TimeoutWhenNoAnswerIsReceivedAndRetryCountIsExceeded() { TransferStub transferWithLowTimeout = new TransferStub(new MemoryStream(new byte[5000])); transferWithLowTimeout.RetryTimeout = new TimeSpan(0); transferWithLowTimeout.RetryCount = 1; transferWithLowTimeout.SetState(new SendReadRequest()); transferWithLowTimeout.OnTimer(); Assert.IsFalse(transferWithLowTimeout.HadNetworkTimeout); transferWithLowTimeout.OnTimer(); Assert.IsTrue(transferWithLowTimeout.HadNetworkTimeout); }
public void ResendsRequest() { TransferStub transferWithLowTimeout = new TransferStub(new MemoryStream()); transferWithLowTimeout.RetryTimeout = new TimeSpan(0); transferWithLowTimeout.SetState(new SendReadRequest()); Assert.IsTrue(transferWithLowTimeout.CommandWasSent(typeof(ReadRequest))); transferWithLowTimeout.SentCommands.Clear(); transferWithLowTimeout.OnTimer(); Assert.IsTrue(transferWithLowTimeout.CommandWasSent(typeof(ReadRequest))); }
public void CallsOnError() { bool OnErrorWasCalled = false; TransferStub transfer = new TransferStub(); transfer.OnError += delegate(ITftpTransfer t, TftpTransferError error) { OnErrorWasCalled = true; Assert.AreEqual(transfer, t); Assert.IsInstanceOf <TftpErrorPacket>(error); Assert.AreEqual(123, ((TftpErrorPacket)error).ErrorCode); Assert.AreEqual("My Error", ((TftpErrorPacket)error).ErrorMessage); }; Assert.IsFalse(OnErrorWasCalled); transfer.SetState(new ReceivedError(new TftpErrorPacket(123, "My Error"))); Assert.IsTrue(OnErrorWasCalled); }
public void Setup() { ms = new MemoryStream(); transfer = new TransferStub(ms); transfer.SetState(new SendReadRequest()); }
public void Setup() { transfer = new TransferStub(); transfer.SetState(new CancelledByUser(TftpErrorPacket.IllegalOperation)); }
public void Setup() { transfer = new TransferStub(new MemoryStream(new byte[5000])); transfer.SetState(new SendWriteRequest()); }
public void Setup() { transfer = new TransferStub(); transfer.SetState(new ReceivedError(new TftpErrorPacket(123, "Error"))); }
public void Setup() { transfer = new TransferStub(); transfer.SetState(new StartOutgoingRead()); }
public void Setup() { transfer = new TransferStub(); transfer.SetState(new StartIncomingRead(new TransferOption[] { new TransferOption("tsize", "0") })); }
public void Setup() { transfer = new TransferStub(); transfer.SetState(new Closed()); }