public void TrainSegmentModelClassUpdatePageFootnotesMethodSetsPageFootnotesElementsSymbolPropertiesIfIdAppearsInParameter()
        {
            TrainSegmentModel testObject    = GetTestObject(null, null, null, null);
            int           testFootnoteCount = testObject.PageFootnotes.Count;
            List <string> idsToChange       = new List <string>();

            foreach (FootnoteDisplayModel fdm in testObject.PageFootnotes)
            {
                if (_rnd.NextBoolean())
                {
                    idsToChange.Add(fdm.NoteId);
                }
            }
            Note[] testParameter = GetTestNotes(idsToChange);

            testObject.UpdatePageFootnotes(testParameter);

            Assert.AreEqual(testFootnoteCount, testObject.PageFootnotes.Count);
            for (int i = 0; i < testFootnoteCount; ++i)
            {
                if (idsToChange.Contains(testObject.PageFootnotes[i].NoteId))
                {
                    Assert.AreEqual(testParameter.First(n => n.Id == testObject.PageFootnotes[i].NoteId).Symbol, testObject.PageFootnotes[i].Symbol);
                }
            }
        }
        public void TrainSegmentModelClassUpdatePageFootnotesMethodChangesPageFootnotesElementsWithIdsThatAppearInParameter()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);
            int testFootnoteCount        = testObject.PageFootnotes.Count;
            List <FootnoteDisplayModel> pageFootnotesCopy = testObject.PageFootnotes.ToList();
            List <string> idsToChange = new List <string>();

            foreach (FootnoteDisplayModel fdm in testObject.PageFootnotes)
            {
                if (_rnd.NextBoolean())
                {
                    idsToChange.Add(fdm.NoteId);
                }
            }
            Note[] testParameter = GetTestNotes(idsToChange);

            testObject.UpdatePageFootnotes(testParameter);

            Assert.AreEqual(testFootnoteCount, testObject.PageFootnotes.Count);
            for (int i = 0; i < testFootnoteCount; ++i)
            {
                if (idsToChange.Contains(testObject.PageFootnotes[i].NoteId))
                {
                    Assert.AreNotSame(pageFootnotesCopy[i], testObject.PageFootnotes[i]);
                }
                else
                {
                    Assert.AreSame(pageFootnotesCopy[i], testObject.PageFootnotes[i]);
                }
            }
        }
        public void TrainSegmentModelClassSplitAtIndexMethodReturnsNullIfParameterIsSameAsIndexOfLastTimingEntry()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.SplitAtIndex(testObject.Timings.Count - 1, _rnd.Next());

            Assert.IsNull(testOutput);
        }
        public void TrainSegmentModelClassCopyMethodReturnsObjectWithPageFootnotesPropertyOfCorrectLength()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.Copy();

            Assert.AreEqual(testObject.PageFootnotes.Count, testOutput.PageFootnotes.Count);
        }
        public void TrainSegmentModelClassCopyMethodReturnsObjectWithToWorkCellPropertyWithCorrectDisplayedTextProperty()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.Copy();

            Assert.AreEqual(testObject.ToWorkCell.DisplayedText, testOutput.ToWorkCell.DisplayedText);
        }
        public void TrainSegmentModelClassCopyMethodReturnsObjectWithToWorkCellPropertyWithCorrectActualTimeProperty()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.Copy();

            Assert.AreEqual(testObject.ToWorkCell.ActualTime, testOutput.ToWorkCell.ActualTime);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodReturnsNullIfParameterIsEqualToTimingsPropertyCountProperty()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.SplitAtIndex(testObject.Timings.Count, _rnd.Next());

            Assert.IsNull(testOutput);
        }
        public void TrainSegmentModelClassCopyMethodReturnsObjectWithCorrectContinuesLaterProperty()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.Copy();

            Assert.AreEqual(testObject.ContinuesLater, testOutput.ContinuesLater);
        }
        public void TrainSegmentModelClassCopyMethodReturnsObjectWithCorrectLocoDiagramProperty()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.Copy();

            Assert.AreEqual(testObject.LocoDiagram, testOutput.LocoDiagram);
        }
        public void TrainSegmentModelClassCopyMethodReturnsObjectWithCorrectInlineNoteProperty()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.Copy();

            Assert.AreEqual(testObject.InlineNote, testOutput.InlineNote);
        }
        public void TrainSegmentModelClassCopyMethodReturnsObjectWithCorrectIncludeSeparatorBelowProperty()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.Copy();

            Assert.AreEqual(testObject.IncludeSeparatorBelow, testOutput.IncludeSeparatorBelow);
        }
        public void TrainSegmentModelClassCopyMethodReturnsObjectWithCorrectHalfOfDayProperty()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.Copy();

            Assert.AreEqual(testObject.HalfOfDay, testOutput.HalfOfDay);
        }
        public void TrainSegmentModelClassHalfOfDayPropertyHasCorrectValueIfFirstTimingPointIsAtNoon()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, HalfOfDay.Noon);

            string testOutput = testObject.HalfOfDay;

            Assert.AreEqual("noon", testOutput);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodReturnsNullIfParameterIsZero()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.SplitAtIndex(0, _rnd.Next());

            Assert.IsNull(testOutput);
        }
Ejemplo n.º 15
0
        public void TrainSegmentModelComparerClassCompareMethodWithCommonLocationsCase8()
        {
            TrainSegmentModelComparer testObject = new TrainSegmentModelComparer(new List <LocationDisplayModel>
            {
                new LocationDisplayModel {
                    LocationKey = "A"
                },
                new LocationDisplayModel {
                    LocationKey = "B"
                },
                new LocationDisplayModel {
                    LocationKey = "C"
                },
                new LocationDisplayModel {
                    LocationKey = "D"
                },
            });
            TrainSegmentModel testParam0 = new TrainSegmentModel(
                new List <ILocationEntry>
            {
                new TrainLocationTimeModel {
                    LocationKey = "A", ActualTime = new TimeOfDay(10, 0)
                },
                new TrainLocationTimeModel {
                    LocationKey = "B", ActualTime = new TimeOfDay(10, 7)
                },
                new TrainLocationTimeModel {
                    LocationKey = "C", ActualTime = new TimeOfDay(10, 33)
                },
                new TrainLocationTimeModel {
                    LocationKey = "D", ActualTime = new TimeOfDay(10, 38, 15)
                },
            }
                );
            TrainSegmentModel testParam1 = new TrainSegmentModel(
                new List <ILocationEntry>
            {
                new TrainLocationTimeModel {
                    LocationKey = "A", ActualTime = new TimeOfDay(9, 0)
                },
                new TrainLocationTimeModel {
                    LocationKey = "B", ActualTime = new TimeOfDay(9, 45, 15)
                },
                new TrainLocationTimeModel {
                    LocationKey = "C", ActualTime = new TimeOfDay(10, 33)
                },
                new TrainLocationTimeModel {
                    LocationKey = "D", ActualTime = new TimeOfDay(10, 38, 15)
                },
            }
                );

            Tuple <int, TrainSegmentModel> testOutput = testObject.Compare(testParam0, testParam1);

            Assert.AreEqual(1, testOutput.Item1);
            Assert.IsNull(testOutput.Item2);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodReturnsNonNullResultIfParameterIsGreaterThanZeroAndLessThanFinalIndexOfTimingsProperty()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);
            int testParam0 = _rnd.Next(testObject.Timings.Count - 2) + 1;

            TrainSegmentModel testOutput = testObject.SplitAtIndex(testParam0, _rnd.Next());

            Assert.IsNotNull(testOutput);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodReturnsNullIfParameterIsEqualToOrGreaterThanTimingsPropertyCountProperty()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);
            int testParam0 = _rnd.Next(int.MaxValue - testObject.Timings.Count) + testObject.Timings.Count;

            TrainSegmentModel testOutput = testObject.SplitAtIndex(testParam0, _rnd.Next());

            Assert.IsNull(testOutput);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodReturnsObjectWithPageFootnotesPropertyOfCorrectLength()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);
            int testParam0 = _rnd.Next(testObject.Timings.Count - 2) + 1;
            int testParam1 = _rnd.Next(testObject.Timings.Count - testParam0);

            TrainSegmentModel testOutput = testObject.SplitAtIndex(testParam0, testParam1);

            Assert.AreEqual(testObject.PageFootnotes.Count, testOutput.PageFootnotes.Count);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodReturnsObjectWithContinuationFromEarlierPropertyEqualToTrue()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);
            int testParam0 = _rnd.Next(testObject.Timings.Count - 2) + 1;
            int testParam1 = _rnd.Next(testObject.Timings.Count - testParam0);

            TrainSegmentModel testOutput = testObject.SplitAtIndex(testParam0, testParam1);

            Assert.IsTrue(testOutput.ContinuationFromEarlier);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodReturnsObjectWithCorrectTrainIdProperty()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);
            int testParam0 = _rnd.Next(testObject.Timings.Count - 2) + 1;
            int testParam1 = _rnd.Next(testObject.Timings.Count - testParam0);

            TrainSegmentModel testOutput = testObject.SplitAtIndex(testParam0, testParam1);

            Assert.AreEqual(testObject.TrainId, testOutput.TrainId);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodSetsInlineNotePropertyOfParameterToEmptyString()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);
            int testParam0 = _rnd.Next(testObject.Timings.Count - 2) + 1;
            int testParam1 = _rnd.Next(testObject.Timings.Count - testParam0);

            _ = testObject.SplitAtIndex(testParam0, testParam1);

            Assert.AreEqual("", testObject.InlineNote);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodSetsContinuesLaterPropertyOfOriginalSegmentToTrue()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, false, null);
            int testParam0 = _rnd.Next(testObject.Timings.Count - 2) + 1;
            int testParam1 = _rnd.Next(testObject.Timings.Count - testParam0);

            _ = testObject.SplitAtIndex(testParam0, testParam1);

            Assert.IsTrue(testObject.ContinuesLater);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodReducesNumberOfTimingsInOriginalSegmentToSplitPointPlusOverlap()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);
            int testParam0 = _rnd.Next(testObject.Timings.Count - 2) + 1;
            int testParam1 = _rnd.Next(testObject.Timings.Count - testParam0);

            _ = testObject.SplitAtIndex(testParam0, testParam1);

            Assert.AreEqual(testParam0 + testParam1, testObject.Timings.Count);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodReturnsNullIfParameterIsLessThanZero()
        {
            int testParam0 = _rnd.Next(int.MaxValue - 1) * -1 - 1;
            int testParam1 = _rnd.Next();
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.SplitAtIndex(testParam0, testParam1);

            Assert.IsNull(testOutput);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodReturnsObjectWithCorrectContinuesLaterProperty()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);
            int  testParam0             = _rnd.Next(testObject.Timings.Count - 2) + 1;
            int  testParam1             = _rnd.Next(testObject.Timings.Count - testParam0);
            bool originalContinuesLater = testObject.ContinuesLater;

            TrainSegmentModel testOutput = testObject.SplitAtIndex(testParam0, testParam1);

            Assert.AreEqual(originalContinuesLater, testOutput.ContinuesLater);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodReducesNumberOfTimingsInOriginalSegmentIfSplitPointPlusOverlapIsLessThanTotalNumberOfTimings()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);
            int testParam0  = _rnd.Next(testObject.Timings.Count - 2) + 1;
            int testParam1  = _rnd.Next(testObject.Timings.Count - testParam0);
            int timingCount = testObject.Timings.Count;

            _ = testObject.SplitAtIndex(testParam0, testParam1);

            Assert.IsTrue(testObject.Timings.Count < timingCount);
        }
        public void TrainSegmentModelClassSplitAtIndexMethodDoesNotReduceNumberOfTimingsInOriginalSegmentIfOverlapIsGreaterThanNumberOfTimingsBetweenSplitPointAndEnd()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);
            int testParam0  = _rnd.Next(testObject.Timings.Count - 2) + 1;
            int testParam1  = _rnd.Next(int.MaxValue - testObject.Timings.Count) + testObject.Timings.Count - testParam0;
            int timingCount = testObject.Timings.Count;

            _ = testObject.SplitAtIndex(testParam0, testParam1);

            Assert.AreEqual(timingCount, testObject.Timings.Count);
        }
        public void TrainSegmentModelClassCopyMethodReturnsObjectWithTimingsPropertyWithContentsWithCorrectLocationKeyProperties()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.Copy();

            for (int i = 0; i < testOutput.Timings.Count; ++i)
            {
                Assert.AreEqual(testObject.Timings[i].LocationKey, testOutput.Timings[i].LocationKey);
            }
        }
        public void TrainSegmentModelClassCopyMethodReturnsObjectWithPageFootnotesPropertyContainingObjectsWithCorrectDisplayOnPageProperty()
        {
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);

            TrainSegmentModel testOutput = testObject.Copy();

            for (int i = 0; i < testObject.PageFootnotes.Count; ++i)
            {
                Assert.AreEqual(testObject.PageFootnotes[i].DisplayOnPage, testOutput.PageFootnotes[i].DisplayOnPage);
            }
        }
        public void TrainSegmentModelClassSplitAtIndexMethodReturnsObjectWithCorrectNumberOfTimings()
        {
            // The correct number of timings is: the number of elements from the split point to the end.
            TrainSegmentModel testObject = GetTestObject(null, null, null, null);
            int testParam0 = _rnd.Next(testObject.Timings.Count - 2) + 1;
            int testParam1 = _rnd.Next(testObject.Timings.Count - testParam0);
            List <ILocationEntry> savedTimings = testObject.Timings.Select(t => t.Copy()).ToList();

            TrainSegmentModel testOutput = testObject.SplitAtIndex(testParam0, testParam1);

            Assert.AreEqual(savedTimings.Count - testParam0, testOutput.Timings.Count);
        }