示例#1
0
        public void SendsWriteRequest()
        {
            TransferStub transfer = new TransferStub(new MemoryStream(new byte[5000]));

            transfer.SetState(new SendWriteRequest());
            Assert.IsTrue(transfer.CommandWasSent(typeof(WriteRequest)));
        }
示例#2
0
        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);
        }
示例#3
0
        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)));
        }
示例#4
0
        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);
        }
示例#5
0
 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));
 }
示例#7
0
 public void Setup()
 {
     transfer = new TransferStub(new MemoryStream(new byte[5000]));
     transfer.SetState(new SendWriteRequest());
 }
示例#8
0
 public void Setup()
 {
     transfer = new TransferStub();
     transfer.SetState(new ReceivedError(new TftpErrorPacket(123, "Error")));
 }
示例#9
0
 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") }));
 }
示例#11
0
 public void Setup()
 {
     transfer = new TransferStub();
     transfer.SetState(new Closed());
 }