Beispiel #1
0
        /// <summary>Compare two task lists.</summary>
        /// <param name="listA">The first list.</param>
        /// <param name="listB">The second list.</param>
        /// <returns>true if identical, false otherwise.</returns>
        public bool CompareTaskLists(PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskList listA,
                                     PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskList listB)
        {
            bool equal = true;

            if (listA.Count == listB.Count)
            {
                int indexA = 0;
                int indexB = 0;

                for (; indexA < listA.Count; ++indexA, ++indexB)
                {
                    // Only comparing the task id
                    if (listA[indexA].taskId != listA[indexA].taskId)
                    {
                        equal = false;
                        break;
                    }
                }
            }
            else
            {
                equal = false;
            }

            return(equal);
        }
Beispiel #2
0
        public void EnumTransferTaskThreeEntriesThreeChunks()
        {
            _transferReply.Body.transferTaskList = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskList();
            _transferReply.Body.transferTaskList.Add(_transferTask1);
            _transferReply.Body.transferTaskList.Add(_transferTask2);
            _transferReply.Body.transferTaskList.Add(_transferTask3);
            _transferReply.Body.endOfEnum = false;

            var transferReplyPart2 = new PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskOutput();

            transferReplyPart2.Body = new PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskOutputBody();
            transferReplyPart2.Body.transferTaskList = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskList();
            transferReplyPart2.Body.transferTaskList.Add(_transferTask4);
            transferReplyPart2.Body.transferTaskList.Add(_transferTask5);
            transferReplyPart2.Body.transferTaskList.Add(_transferTask6);
            transferReplyPart2.Body.endOfEnum = false;

            var transferReplyPart3 = new PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskOutput();

            transferReplyPart3.Body = new PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskOutputBody();
            transferReplyPart3.Body.transferTaskList = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskList();
            transferReplyPart3.Body.transferTaskList.Add(_transferTask7);
            transferReplyPart3.Body.transferTaskList.Add(_transferTask8);
            transferReplyPart3.Body.endOfEnum = true;

            var expectedTaskList = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskList();

            expectedTaskList.AddRange(_transferReply.Body.transferTaskList);
            expectedTaskList.AddRange(transferReplyPart2.Body.transferTaskList);
            expectedTaskList.AddRange(transferReplyPart3.Body.transferTaskList);

            var transferList = new List <PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskOutput>();

            transferList.Add(_transferReply);
            transferList.Add(transferReplyPart2);
            transferList.Add(transferReplyPart3);
            ushort currentTransferListIndex = 0;

            _fileTransferPortMock.Setup(x => x.enumTransferTask(
                                            It.IsAny <PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskInput>()))
            .Throws(new Exception("Invalid invocation"));

            _fileTransferPortMock.Setup(x => x.enumTransferTask(
                                            It.Is <PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskInput>(
                                                t => t.Body.enumPos < transferList.Count && t.Body.enumPos == currentTransferListIndex && t.Body.startDate == _startTransferDate && t.Body.endDate == _endTransferDate)))
            .Returns(() => transferList[currentTransferListIndex++]);

            PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskList taskListResult;
            bool lSuccess = _t2gFileDistMgr.EnumTransferTask(_startTransferDate, _endTransferDate, out taskListResult);

            _fileTransferPortMock.Verify(x => x.enumTransferTask(
                                             It.Is <PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskInput>
                                                 (l => l.Body.startDate == _startTransferDate && l.Body.endDate == _endTransferDate)),
                                         Times.Exactly(3));

            Assert.IsTrue(lSuccess, "EnumTransferTask didn't succeed as expected");
            Assert.IsTrue(CompareTaskLists(expectedTaskList, taskListResult));
        }
Beispiel #3
0
        public void Setup()
        {
            _fileTransferPortMock = new Mock <PIS.Ground.Core.T2G.WebServices.FileTransfer.FileTransferPortType>();
            _notifierTargetMock   = new Mock <PIS.Ground.Core.T2G.IT2GNotifierTarget>();
            _t2gFileDistMgr       = new T2GFileDistributionManager(new T2GSessionData(), _notifierTargetMock.Object, _fileTransferPortMock.Object);
            _transferTaskList     = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskList();
            _transferTask1        = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskStruct();
            _transferTask1.taskId = 67;
            _transferTask2        = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskStruct();
            _transferTask2.taskId = 72;
            _transferTask3        = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskStruct();
            _transferTask3.taskId = 98;
            _transferTask4        = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskStruct();
            _transferTask4.taskId = 118;
            _transferTask5        = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskStruct();
            _transferTask5.taskId = 128;
            _transferTask6        = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskStruct();
            _transferTask6.taskId = 138;
            _transferTask7        = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskStruct();
            _transferTask7.taskId = 148;
            _transferTask8        = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskStruct();
            _transferTask8.taskId = 158;
            _transferReply        = new PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskOutput();
            _transferReply.Body   = new PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskOutputBody();
            _transferReply.Body.transferTaskList = null;
            _transferReply.Body.endOfEnum        = true;

            //Build Mock folder for a request
            _remoteFolderMock = new Mock <IRemoteFolderClass>();

            //build Mock answer for enumFolders
            _testFolder = new folderInfoStruct();

            //Build fake answer to enumFolders function
            _enumFoldersOutput                 = new enumFoldersOutput();
            _enumFoldersOutput.Body            = new enumFoldersOutputBody();
            _enumFoldersOutput.Body.endOfEnum  = true;
            _enumFoldersOutput.Body.folderList = new folderList();
            _enumFoldersOutput.Body.folderList.Add(_testFolder);
        }
Beispiel #4
0
        public void EnumTransferTaskThreeEntriesEmptyFirstChunk()
        {
            _transferReply.Body.transferTaskList = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskList();
            _transferReply.Body.endOfEnum        = false;

            var transferReplyPart2 = new PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskOutput();

            transferReplyPart2.Body = new PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskOutputBody();
            transferReplyPart2.Body.transferTaskList = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskList();
            transferReplyPart2.Body.transferTaskList.Add(_transferTask1);
            transferReplyPart2.Body.transferTaskList.Add(_transferTask2);
            transferReplyPart2.Body.transferTaskList.Add(_transferTask3);
            transferReplyPart2.Body.endOfEnum = true;

            var expectedTaskList = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskList();

            expectedTaskList.AddRange(_transferReply.Body.transferTaskList);
            expectedTaskList.AddRange(transferReplyPart2.Body.transferTaskList);

            var transferList = new List <PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskOutput>();

            transferList.Add(_transferReply);
            transferList.Add(transferReplyPart2);
            var currentTransferListIndex = 0;

            _fileTransferPortMock.Setup(x => x.enumTransferTask(
                                            It.IsAny <PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskInput>()))
            .Returns(() => transferList[currentTransferListIndex++]);

            PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskList taskListResult;
            bool lSuccess = _t2gFileDistMgr.EnumTransferTask(_startTransferDate, _endTransferDate, out taskListResult);

            _fileTransferPortMock.Verify(x => x.enumTransferTask(
                                             It.Is <PIS.Ground.Core.T2G.WebServices.FileTransfer.enumTransferTaskInput>
                                                 (l => l.Body.startDate == _startTransferDate && l.Body.endDate == _endTransferDate)),
                                         Times.Exactly(2));

            Assert.IsTrue(CompareTaskLists(expectedTaskList, taskListResult));
            Assert.IsTrue(lSuccess);
        }