/// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="locations">Locations to include in this template.</param>
 /// <param name="notes">Footnote definitions to include in this template.</param>
 /// <param name="classes">Train classes to include in this template.</param>
 /// <param name="boxes">Signalboxes to include in this template.</param>
 public DocumentTemplate(IEnumerable <Location> locations, IEnumerable <Note> notes, IEnumerable <TrainClass> classes, IEnumerable <Signalbox> boxes)
 {
     Locations       = new LocationCollection(locations ?? Array.Empty <Location>());
     NoteDefinitions = new NoteCollection(notes ?? Array.Empty <Note>());
     TrainClasses    = new TrainClassCollection(classes ?? Array.Empty <TrainClass>());
     Signalboxes     = new SignalboxCollection(boxes ?? Array.Empty <Signalbox>());
 }
        /// <summary>
        /// Default constructor - sets the version number and creates empty objects for deep properties.
        /// </summary>
        public TimetableDocument()
        {
            Version = 2;

            TrainClassList = new TrainClassCollection();
            TrainClassList.TrainClassAdd    += TrainClassChangedHandler;
            TrainClassList.TrainClassRemove -= TrainClassChangedHandler;
            TrainList                                   = new TrainCollection();
            TrainList.TrainAdd                         += TrainAddHandler;
            TrainList.TrainRemove                      += TrainRemoveHandler;
            LocationList                                = new LocationCollection();
            LocationList.LocationAdd                   += LocationChangedHandler;
            LocationList.LocationRemove                += LocationChangedHandler;
            DownTrainsDisplay                           = new TimetableSectionModel(Direction.Down, LocationList);
            UpTrainsDisplay                             = new TimetableSectionModel(Direction.Up, LocationList);
            Signalboxes                                 = new SignalboxCollection();
            Signalboxes.SignalboxAdd                   += SignalboxChangedHandler;
            Signalboxes.SignalboxRemove                += SignalboxChangedHandler;
            SignalboxHoursSets                          = new SignalboxHoursSetCollection();
            SignalboxHoursSets.SignalboxHoursSetAdd    += SignalboxHoursSetChangedHandler;
            SignalboxHoursSets.SignalboxHoursSetRemove += SignalboxHoursSetChangedHandler;
            Options                     = new DocumentOptions();
            NoteDefinitions             = new NoteCollection();
            NoteDefinitions.NoteAdd    += NoteChangedHandler;
            NoteDefinitions.NoteRemove += NoteChangedHandler;
            ExportOptions               = new DocumentExportOptions();
        }
Beispiel #3
0
        public void SignalboxCollectionClassConstructorWithIEnumerableParameterReturnsCollectionOfCorrectSize()
        {
            List <Signalbox> testData = SignalboxHelpers.GetSignalboxList(0, 64);

            SignalboxCollection collection = new SignalboxCollection(testData);

            Assert.AreEqual(testData.Count, collection.Count);
        }
Beispiel #4
0
        public void SignalboxCollectionClassCopyMethodReturnsDifferentObject()
        {
            List <Signalbox>    testData         = SignalboxHelpers.GetSignalboxList(0, 64);
            SignalboxCollection sourceCollection = new SignalboxCollection(testData);

            SignalboxCollection testCollection = sourceCollection.Copy();

            Assert.AreNotSame(testCollection, sourceCollection);
        }
Beispiel #5
0
        public void SignalboxCollectionClassCopyMethodReturnsCollectionOfCorrectSize()
        {
            List <Signalbox>    testData         = SignalboxHelpers.GetSignalboxList(0, 64);
            SignalboxCollection sourceCollection = new SignalboxCollection(testData);

            SignalboxCollection testCollection = sourceCollection.Copy();

            Assert.AreEqual(sourceCollection.Count, testCollection.Count);
        }
Beispiel #6
0
        public void SignalboxCollectionClassIndexerWithIntParameterReturnsCorrectObject()
        {
            List <Signalbox>    testData       = SignalboxHelpers.GetSignalboxList(1, 64);
            SignalboxCollection testCollection = new SignalboxCollection(testData);
            int idx = _random.Next(testData.Count);

            Signalbox testObject = testCollection[idx];

            Assert.AreSame(testData[idx], testObject);
        }
Beispiel #7
0
        public void SignalboxCollectionClassConstructorWithIEnumerableParameterReturnsCollectionWithCorrectContents()
        {
            List <Signalbox> testData = SignalboxHelpers.GetSignalboxList(0, 64);

            SignalboxCollection collection = new SignalboxCollection(testData);

            for (int i = 0; i < testData.Count; ++i)
            {
                Assert.AreSame(testData[i], collection[i]);
            }
        }
Beispiel #8
0
        public void SignalboxCollectionClassCopyMethodReturnsCollectionWhoseContentsHaveCorrectCodeProperties()
        {
            List <Signalbox>    testData         = SignalboxHelpers.GetSignalboxList(0, 64);
            SignalboxCollection sourceCollection = new SignalboxCollection(testData);

            SignalboxCollection testCollection = sourceCollection.Copy();

            for (int i = 0; i < sourceCollection.Count; ++i)
            {
                Assert.AreEqual(sourceCollection[i].Code, testCollection[i].Code);
            }
        }
Beispiel #9
0
        public void SignalboxCollectionClassCopyMethodReturnsCollectionWhoseContentsAreDifferentObjects()
        {
            List <Signalbox>    testData         = SignalboxHelpers.GetSignalboxList(0, 64);
            SignalboxCollection sourceCollection = new SignalboxCollection(testData);

            SignalboxCollection testCollection = sourceCollection.Copy();

            for (int i = 0; i < sourceCollection.Count; ++i)
            {
                Assert.AreNotSame(sourceCollection[i], testCollection[i]);
            }
        }
Beispiel #10
0
        public void SignalboxCollectionClassIndexerWithIntParameterDoesNotRaiseSignalboxRemoveEventIfSetIsCalledWithSameObject()
        {
            List <Signalbox>    testData       = SignalboxHelpers.GetSignalboxList(1, 64);
            SignalboxCollection testCollection = new SignalboxCollection(testData);
            int invocations = 0;

            testCollection.SignalboxRemove += new Events.SignalboxEventHandler((o, e) => { invocations++; });
            int idx = _random.Next(testData.Count);

            testCollection[idx] = testData[idx];

            Assert.AreEqual(0, invocations);
        }
Beispiel #11
0
        public void SignalboxCollectionClassIndexerWithIntParameterRaisesSignalboxRemoveEventWithCorrectEventArgsIfSetIsCalledWithDifferenObject()
        {
            List <Signalbox>    testData       = SignalboxHelpers.GetSignalboxList(1, 64);
            SignalboxCollection testCollection = new SignalboxCollection(testData);
            Signalbox           testObject     = SignalboxHelpers.GetSignalbox();
            Signalbox           capturedBox    = null;

            testCollection.SignalboxRemove += new Events.SignalboxEventHandler((o, e) => { capturedBox = e.Signalbox; });
            int idx = _random.Next(testData.Count);

            testCollection[idx] = testObject;

            Assert.AreSame(testData[idx], capturedBox);
        }
 /// <summary>
 /// Default constructor.
 /// </summary>
 public SignalboxListEditForm(SignalboxCollection model)
 {
     _rowMap = new Dictionary <string, DataGridViewRow>();
     InitializeComponent();
     Model = model;
 }
Beispiel #13
0
        public void SignalboxCollectionClassParameterlessConstructorReturnsEmptyCollection()
        {
            SignalboxCollection collection = new SignalboxCollection();

            Assert.AreEqual(0, collection.Count);
        }