Exemplo n.º 1
0
        public void CancellableTransferTaskInfo_IsMatching_Match()
        {
            var lTemplate = new DataPackageService.CancellableTransferTaskInfo(514, null);
            var lTaskInfo = new DataPackageService.CancellableTransferTaskInfo(718, null);

            lTemplate.Elements = new List <string>();
            lTemplate.Elements.AddRange(new string[] { "train1" });
            lTaskInfo.Elements = new List <string>();
            lTaskInfo.Elements.AddRange(new string[] { "train1" });
            bool lMatching = lTaskInfo.IsMatching(lTemplate);

            Assert.IsTrue(lMatching, "Match of elements lists 1/4");

            lTemplate.Elements = new List <string>();
            lTemplate.Elements.AddRange(new string[] { "train1", "train2" });
            lTaskInfo.Elements = new List <string>();
            lTaskInfo.Elements.AddRange(new string[] { "train1" });
            lMatching = lTaskInfo.IsMatching(lTemplate);
            Assert.IsTrue(lMatching, "Match of elements lists 2/4");

            lTemplate.Elements = new List <string>();
            lTemplate.Elements.AddRange(new string[] { "train1", "train2" });
            lTaskInfo.Elements = new List <string>();
            lTaskInfo.Elements.AddRange(new string[] { "train2", "train1" });
            lMatching = lTaskInfo.IsMatching(lTemplate);
            Assert.IsTrue(lMatching, "Match of elements lists 3/4");

            lTemplate.Elements = new List <string>();
            lTemplate.Elements.AddRange(new string[] { "train3", "train1", "train2" });
            lTaskInfo.Elements = new List <string>();
            lTaskInfo.Elements.AddRange(new string[] { "train2", "train1" });
            lMatching = lTaskInfo.IsMatching(lTemplate);
            Assert.IsTrue(lMatching, "Match of elements lists 4/4");
        }
Exemplo n.º 2
0
        public void CancellableTransferTaskInfo_IsMatching_asPredicate()
        {
            var lTemplate = new DataPackageService.CancellableTransferTaskInfo(514, null);

            lTemplate.Elements = new List <string>(new string[] { "train1", "train2" });
            var lTaskInfoList = new List <DataPackageService.CancellableTransferTaskInfo>();
            var lTaskInfo1    = new DataPackageService.CancellableTransferTaskInfo(718, null);

            lTaskInfo1.Elements = new List <string>(new string[] { "train2" });
            lTaskInfoList.Add(lTaskInfo1);
            var lTaskInfo2 = new DataPackageService.CancellableTransferTaskInfo(465, null);

            lTaskInfo2.Elements = new List <string>(new string[] { "train15" });
            lTaskInfoList.Add(lTaskInfo2);
            var lTaskInfo3 = new DataPackageService.CancellableTransferTaskInfo(112, null);

            lTaskInfo3.Elements = new List <string>(new string[] { "train2", "train1" });
            lTaskInfoList.Add(lTaskInfo3);

            var lMatchList = lTaskInfoList.FindAll((lTask) => lTask.IsMatching(lTemplate));

            Assert.AreEqual(2, lMatchList.Count, "Testing as a predicate. Checking the number of matches");
            Assert.IsTrue(718 == lMatchList[0].TaskID, "Testing as a predicate. Checking the first match");
            Assert.IsTrue(112 == lMatchList[1].TaskID, "Testing as a predicate. Checking the second match");
        }
Exemplo n.º 3
0
        public void CancellableTransferTaskInfo_IsMatching_partialMismatch()
        {
            var lTemplate = new DataPackageService.CancellableTransferTaskInfo(514, null);
            var lTaskInfo = new DataPackageService.CancellableTransferTaskInfo(718, null);

            lTemplate.Elements = new List <string>();
            lTemplate.Elements.AddRange(new string[] { "train1", "train2" });
            lTaskInfo.Elements = new List <string>();
            lTaskInfo.Elements.AddRange(new string[] { "train15", "train1" });
            bool lMatching = lTaskInfo.IsMatching(lTemplate);

            Assert.IsFalse(lMatching, "Parial mismatch of elements lists 1/3");

            lTemplate.Elements = new List <string>();
            lTemplate.Elements.AddRange(new string[] { "train1", "train2" });
            lTaskInfo.Elements = new List <string>();
            lTaskInfo.Elements.AddRange(new string[] { "train15", "train2", "train1" });
            lMatching = lTaskInfo.IsMatching(lTemplate);
            Assert.IsFalse(lMatching, "Parial mismatch of elements lists 2/3");

            lTemplate.Elements = new List <string>();
            lTemplate.Elements.AddRange(new string[] { "train1", "train2" });
            lTaskInfo.Elements = new List <string>();
            lTaskInfo.Elements.AddRange(new string[] { "train1", "train2", "train17" });
            lMatching = lTaskInfo.IsMatching(lTemplate);
            Assert.IsFalse(lMatching, "Parial mismatch of elements lists 3/3");
        }
Exemplo n.º 4
0
        public void cancelTransferTasks_error()
        {
            int[] lTaskIDs   = { 364, 547 };
            var   lInputList = new List <DataPackageService.CancellableTransferTaskInfo>();
            var   lTask1     = new DataPackageService.CancellableTransferTaskInfo(lTaskIDs[0], null);

            lInputList.Add(lTask1);
            var lTask2 = new DataPackageService.CancellableTransferTaskInfo(lTaskIDs[1], null);

            lInputList.Add(lTask2);

            bool   lSuccess      = false;
            string lErrorMessage = "Cancel error";

            _train2groundClientMock.Setup(x => x.CancelTransferTask(
                                              It.IsAny <int>(), out lErrorMessage));

            lSuccess = DataPackageServiceInstrumented.cancelTransferTasks(lInputList);

            _train2groundClientMock.Verify(x => x.CancelTransferTask(
                                               It.Is <int>((lVal) => lVal == lTaskIDs[0]), out lErrorMessage),
                                           Times.Exactly(1), "Error during cancel 1/2");

            _train2groundClientMock.Verify(x => x.CancelTransferTask(
                                               It.Is <int>((lVal) => lVal == lTaskIDs[1]), out lErrorMessage),
                                           Times.Exactly(1), "Error during cancel 2/2");

            Assert.IsFalse(lSuccess, "Error during cancel");
        }
Exemplo n.º 5
0
        public void cancelTransferTasks_oneTask()
        {
            int lTaskID1   = 364;
            var lInputList = new List <DataPackageService.CancellableTransferTaskInfo>();
            var lTask1     = new DataPackageService.CancellableTransferTaskInfo(lTaskID1, null);

            lInputList.Add(lTask1);
            bool   lSuccess      = false;
            string lErrorMessage = string.Empty;

            _train2groundClientMock.Setup(x => x.CancelTransferTask(
                                              It.IsAny <int>(), out lErrorMessage));

            lSuccess = DataPackageServiceInstrumented.cancelTransferTasks(lInputList);

            _train2groundClientMock.Verify(x => x.CancelTransferTask(
                                               It.Is <int>((lVal) => lVal == lTaskID1), out lErrorMessage),
                                           Times.Once(), "Input list contains one element");

            Assert.IsTrue(lSuccess, "Input list contains one element");
        }
Exemplo n.º 6
0
        public void CancellableTransferTaskInfo_IsMatching_emptyLists()
        {
            var lTemplate = new DataPackageService.CancellableTransferTaskInfo(514, null);
            var lTaskInfo = new DataPackageService.CancellableTransferTaskInfo(718, null);

            bool lMatching = lTaskInfo.IsMatching(lTemplate);

            Assert.IsFalse(lMatching, "Empty transfer task elements lists 1/6");

            lTemplate.Elements = null;
            lTaskInfo.Elements = new List <string>();
            lMatching          = lTaskInfo.IsMatching(lTemplate);
            Assert.IsFalse(lMatching, "Empty transfer task elements lists 2/6");

            lTemplate.Elements = new List <string>();
            lTaskInfo.Elements = null;
            lMatching          = lTaskInfo.IsMatching(lTemplate);
            Assert.IsFalse(lMatching, "Empty transfer task elements lists 3/6");

            lTemplate.Elements = new List <string>();
            lTaskInfo.Elements = new List <string>();
            lMatching          = lTaskInfo.IsMatching(lTemplate);
            Assert.IsFalse(lMatching, "Empty transfer task elements lists 4/6");

            lTemplate.Elements = new List <string>();
            lTemplate.Elements.AddRange(new string[] { "train1", "train2" });
            lTaskInfo.Elements = new List <string>();
            lMatching          = lTaskInfo.IsMatching(lTemplate);
            Assert.IsFalse(lMatching, "Empty transfer task elements lists 5/6");

            lTemplate.Elements = new List <string>();
            lTaskInfo.Elements = new List <string>();
            lTaskInfo.Elements.AddRange(new string[] { "train15", "train16", "train17" });
            lMatching = lTaskInfo.IsMatching(lTemplate);
            Assert.IsFalse(lMatching, "Empty transfer task elements lists 6/6");
        }
Exemplo n.º 7
0
        public void cancelTransferTasks_multipleTasks()
        {
            int[] lTaskIDs   = { 364, 547, 786 };
            var   lInputList = new List <DataPackageService.CancellableTransferTaskInfo>();
            var   lTask1     = new DataPackageService.CancellableTransferTaskInfo(lTaskIDs[0], null);

            lInputList.Add(lTask1);
            var lTask2 = new DataPackageService.CancellableTransferTaskInfo(lTaskIDs[1], null);

            lInputList.Add(lTask2);
            var lTask3 = new DataPackageService.CancellableTransferTaskInfo(lTaskIDs[2], null);

            lInputList.Add(lTask3);

            bool   lSuccess      = false;
            string lErrorMessage = string.Empty;

            _train2groundClientMock.Setup(x => x.CancelTransferTask(
                                              It.IsAny <int>(), out lErrorMessage));

            lSuccess = DataPackageServiceInstrumented.cancelTransferTasks(lInputList);

            _train2groundClientMock.Verify(x => x.CancelTransferTask(
                                               It.Is <int>((lVal) => lVal == lTaskIDs[0]), out lErrorMessage),
                                           Times.Exactly(1), "Input list contains multiple elements 1/3");

            _train2groundClientMock.Verify(x => x.CancelTransferTask(
                                               It.Is <int>((lVal) => lVal == lTaskIDs[1]), out lErrorMessage),
                                           Times.Exactly(1), "Input list contains multiple elements 2/3");

            _train2groundClientMock.Verify(x => x.CancelTransferTask(
                                               It.Is <int>((lVal) => lVal == lTaskIDs[2]), out lErrorMessage),
                                           Times.Exactly(1), "Input list contains multiple elements 3/3");

            Assert.IsTrue(lSuccess, "Input list contains multiple elements");
        }