예제 #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());
 }
예제 #6
0
 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());
 }
예제 #10
0
 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());
 }