public void TestTransfer()
        {
            var session = new MockTaskSession();

            session.VerifyStart();

            // Basic functionality.
            session.VerifyCommand(
                () => session.Transfer(
                    @"C:\foo.txt",
                    "FOO TXT A",
                    Direction.Send,
                    Mode.Ascii,
                    HostType.Vm,
                    new ParameterExistAction(ExistAction.Replace)),
                "Transfer(direction=Send,exist=Replace,host=Vm,\"hostfile=FOO TXT A\",\"localfile=C:\\\\foo.txt\",mode=Ascii)");

            // Bad parameter type.
            Assert.Throws <ArgumentException>(
                () => session.Transfer("foo.txt", "foo txt a", Direction.Send, Mode.Ascii, HostType.Vm, "wrong!"));
            Assert.Throws <ArgumentNullException>(
                () => session.Transfer(
                    "foo.txt",
                    "foo txt a",
                    Direction.Send,
                    Mode.Ascii,
                    HostType.Vm,
                    new ParameterExistAction(ExistAction.Replace),
                    null));

            // Bad file names.
            Assert.Throws <ArgumentException>(
                () => session.Transfer(string.Empty, "foo txt a", Direction.Send, Mode.Ascii, HostType.Vm));
            Assert.Throws <ArgumentException>(
                () => session.Transfer(null, "foo txt a", Direction.Send, Mode.Ascii, HostType.Vm));
            Assert.Throws <ArgumentException>(
                () => session.Transfer("foo.txt", string.Empty, Direction.Send, Mode.Ascii, HostType.Vm));
            Assert.Throws <ArgumentException>(
                () => session.Transfer("foo.txt", null, Direction.Send, Mode.Ascii, HostType.Vm));

            // Bad AsciiRemap.
            Assert.Throws <ArgumentException>(() => new ParameterAsciiRemap(false, 252));
            Assert.Throws <ArgumentOutOfRangeException>(() => new ParameterAsciiRemap(true, 0));

            // Bad block size.
            Assert.Throws <ArgumentOutOfRangeException>(() => new ParameterBlockSize(0));

            // Bad logical record length.
            Assert.Throws <ArgumentOutOfRangeException>(() => new ParameterSendLogicalRecordLength(0));

            // Bad TsoSendAllocations.
            Assert.Throws <ArgumentOutOfRangeException>(() => new ParameterTsoSendAllocation(TsoAllocationUnits.Cylinders, 0));
            Assert.Throws <ArgumentOutOfRangeException>(() => new ParameterTsoSendAllocation(TsoAllocationUnits.Cylinders, 100, 0));
            Assert.Throws <ArgumentException>(() => new ParameterTsoSendAllocation(TsoAllocationUnits.Avblock, 100, 200));
            Assert.Throws <ArgumentOutOfRangeException>(() => new ParameterTsoSendAllocation(TsoAllocationUnits.Avblock, 100, 200, 0));
            Assert.Throws <ArgumentException>(() => new ParameterTsoSendAllocation(TsoAllocationUnits.Cylinders, 100, 200, 300));

            // Bad buffer size.
            Assert.Throws <ArgumentOutOfRangeException>(() => new ParameterBufferSize(0));

            // All possible options.
            session.VerifyCommand(
                () => session.Transfer(
                    @"C:\foo.txt",
                    "FOO TXT A",
                    Direction.Send,
                    Mode.Ascii,
                    HostType.Tso,
                    new ParameterAsciiCr(false),
                    new ParameterAsciiRemap(true, 252),
                    new ParameterExistAction(ExistAction.Replace),
                    new ParameterSendRecordFormat(RecordFormat.Fixed),
                    new ParameterSendLogicalRecordLength(80),
                    new ParameterBlockSize(1024),
                    new ParameterTsoSendAllocation(TsoAllocationUnits.Avblock, 100, 200, 300),
                    new ParameterBufferSize(4096)),
                "Transfer(allocation=Avblock,avblock=300,blocksize=1024,buffersize=4096,cr=keep,direction=Send,exist=Replace,host=Tso,\"hostfile=FOO TXT A\",\"localfile=C:\\\\foo.txt\",lrecl=80,mode=Ascii,primaryspace=100,recfm=Fixed,remap=yes,secondaryspace=200,windowscodepage=252)");

            // Some ASCII option variations.
            session.VerifyCommand(
                () =>
            {
                return(session.Transfer(
                           @"C:\foo.txt",
                           "FOO TXT A",
                           Direction.Send,
                           Mode.Ascii,
                           HostType.Tso,
                           new ParameterAsciiCr(true),
                           new ParameterAsciiRemap(false)));
            },
                "Transfer(cr=add,direction=Send,host=Tso,\"hostfile=FOO TXT A\",\"localfile=C:\\\\foo.txt\",mode=Ascii,remap=no)");

            // Same thing, using the IEnumerable API.
            session.VerifyCommand(
                () =>
            {
                return(session.Transfer(
                           @"C:\foo.txt",
                           "FOO TXT A",
                           Direction.Send,
                           Mode.Ascii,
                           HostType.Tso,
                           new List <Parameter>
                {
                    new ParameterAsciiCr(true),
                    new ParameterAsciiRemap(false)
                }));
            },
                "Transfer(cr=add,direction=Send,host=Tso,\"hostfile=FOO TXT A\",\"localfile=C:\\\\foo.txt\",mode=Ascii,remap=no)");

            // AsciiCr without Ascii.
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Receive,
                    Mode.Binary,
                    HostType.Tso,
                    new ParameterAsciiCr(true));
            });

            // Same thing, using the IEnumerable API.
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Receive,
                    Mode.Binary,
                    HostType.Tso,
                    new List <Parameter> {
                    new ParameterAsciiCr(true)
                });
            });

            // AsciiRemap without Ascii.
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Receive,
                    Mode.Binary,
                    HostType.Tso,
                    new ParameterAsciiRemap(true));
            });

            // Lrecl without send.
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Receive,
                    Mode.Binary,
                    HostType.Tso,
                    new ParameterSendLogicalRecordLength(80));
            });

            // Lrecl on CICS.
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Send,
                    Mode.Binary,
                    HostType.Cics,
                    new ParameterSendLogicalRecordLength(80));
            });

            // Recfm without send.
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Receive,
                    Mode.Binary,
                    HostType.Tso,
                    new ParameterSendRecordFormat(RecordFormat.Fixed));
            });

            // Recfm on CICS.
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Send,
                    Mode.Binary,
                    HostType.Cics,
                    new ParameterSendRecordFormat(RecordFormat.Fixed));
            });

            // TSO allocation without send.
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Receive,
                    Mode.Binary,
                    HostType.Tso,
                    new ParameterTsoSendAllocation(TsoAllocationUnits.Cylinders, 100));
            });

            // TSO allocation on non-TSO.
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Send,
                    Mode.Binary,
                    HostType.Vm,
                    new ParameterTsoSendAllocation(TsoAllocationUnits.Cylinders, 100));
            });

            // Append with recfm.
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Send,
                    Mode.Binary,
                    HostType.Tso,
                    new ParameterExistAction(ExistAction.Append),
                    new ParameterSendRecordFormat(RecordFormat.Fixed));
            });

            // Append with lrecl.
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Send,
                    Mode.Binary,
                    HostType.Tso,
                    new ParameterExistAction(ExistAction.Append),
                    new ParameterSendLogicalRecordLength(80));
            });

            // Append with TSO allocation.
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Send,
                    Mode.Binary,
                    HostType.Tso,
                    new ParameterExistAction(ExistAction.Append),
                    new ParameterTsoSendAllocation(TsoAllocationUnits.Cylinders, 100));
            });

            // Blocksize without TSO.
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Send,
                    Mode.Binary,
                    HostType.Cics,
                    new ParameterBlockSize(1024));
            });
            Assert.Throws <ArgumentException>(
                () =>
            {
                var result = session.Transfer(
                    "foo.txt",
                    "FOO.TXT",
                    Direction.Send,
                    Mode.Binary,
                    HostType.Vm,
                    new ParameterBlockSize(1024));
            });

            session.Close();
        }