public void TrainCopyFormModelClass_FromTrainMethod_ReturnsObjectWithCorrectTrainNameProperty_IfParameterIsNotNull()
        {
            Train testParam = GetTrain();

            TrainCopyFormModel testOutput = TrainCopyFormModel.FromTrain(testParam);

            Assert.AreEqual(testParam.Headcode, testOutput.TrainName);
        }
        public void TrainCopyFormModelClass_FromTrainMethod_ReturnsObjectWithAddSubtractPropertyEqualToAdd_IfParameterIsNotNull()
        {
            Train testParam = GetTrain();

            TrainCopyFormModel testOutput = TrainCopyFormModel.FromTrain(testParam);

            Assert.AreEqual(AddSubtract.Add, testOutput.AddSubtract);
        }
        public void TrainCopyFormModelClass_FromTrainMethod_ReturnsObjectWithClearInlineNotesPropertyEqualToFalse_IfParameterIsNotNull()
        {
            Train testParam = GetTrain();

            TrainCopyFormModel testOutput = TrainCopyFormModel.FromTrain(testParam);

            Assert.IsFalse(testOutput.ClearInlineNotes);
        }
        public void TrainCopyFormModelClass_FromTrainMethod_ReturnsObjectWithOffsetPropertyEqualToZero_IfParameterIsNotNull()
        {
            Train testParam = GetTrain();

            TrainCopyFormModel testOutput = TrainCopyFormModel.FromTrain(testParam);

            Assert.AreEqual(0, testOutput.Offset);
        }
        public void TrainCopyFormModelClass_FromTrainMethod_ThrowsArgumentNullException_IfParameterIsNull()
        {
            Train testParam = null;

            _ = TrainCopyFormModel.FromTrain(testParam);

            Assert.Fail();
        }
        public void TrainCopyFormModelClass_FromTrainMethod_ThrowsArgumentNullExceptionWithCorrectParamNameProperty_IfParameterIsNull()
        {
            Train testParam = null;

            try
            {
                _ = TrainCopyFormModel.FromTrain(testParam);
                Assert.Fail();
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("train", ex.ParamName);
            }
        }
コード例 #7
0
        private void ShowTrainCopyForm(Train selectedTrain)
        {
            TrainCopyFormModel model = TrainCopyFormModel.FromTrain(selectedTrain);

            using (TrainCopyForm form = new TrainCopyForm {
                Model = model
            })
            {
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                int   offset = model.AddSubtract == AddSubtract.Add ? model.Offset : -model.Offset;
                Train copy   = selectedTrain.Copy(offset);
                if (model.ClearInlineNotes)
                {
                    copy.InlineNote = "";
                }
                Model.TrainList.Add(copy);
            }
        }