public void SignalboxExtensionsClass_ToYamlSignalboxModelMethod_ReturnsObjectWithCorrectIdProperty_IfParameterIsNotNull()
        {
            Signalbox testParam = GetTestObject();

            SignalboxModel testOutput = testParam.ToYamlSignalboxModel();

            Assert.AreEqual(testParam.Id, testOutput.Id);
        }
        public void SignalboxExtensionsClass_ToYamlSignalboxModelMethod_ReturnsObjectWithCorrectTimetableDisplayNameProperty_IfParameterIsNotNull()
        {
            Signalbox testParam = GetTestObject();

            SignalboxModel testOutput = testParam.ToYamlSignalboxModel();

            Assert.AreEqual(testParam.ExportDisplayName, testOutput.TimetableDisplayName);
        }
        public void SignalboxModelExtensionsClass_ToSignalboxMethod_ThrowsArgumentNullException_IfParameterIsNull()
        {
            SignalboxModel testObject = null;

            _ = testObject.ToSignalbox();

            Assert.Fail();
        }
        public void SignalboxModelExtensionsClass_ToSignalboxMethod_ReturnsObjectWithCorrectEditorDisplayNameProperty_IfParameterIsNotNull()
        {
            SignalboxModel testParam = GetModel();

            Signalbox testOutput = testParam.ToSignalbox();

            Assert.AreEqual(testParam.EditorDisplayName, testOutput.EditorDisplayName);
        }
        public void SignalboxModelExtensionsClass_ToSignalboxMethod_ThrowsNullReferenceException_IfParameterIsNull()
        {
            SignalboxModel testParam = null;

            _ = testParam.ToSignalbox();

            Assert.Fail();
        }
        public void SignalboxModelExtensionsClass_ToSignalboxMethod_ThrowsArgumentNullExceptionWithCorrectParamNameProperty_IfParameterIsNull()
        {
            SignalboxModel testObject = null;

            try
            {
                _ = testObject.ToSignalbox();
                Assert.Fail();
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("model", ex.ParamName);
            }
        }
コード例 #7
0
        /// <summary>
        /// Convert a <see cref="SignalboxModel" /> instance to a <see cref="Signalbox" /> instance.
        /// </summary>
        /// <param name="model">The object to convert.</param>
        /// <returns>A <see cref="Signalbox" /> instance containing the same data as the parameter.</returns>
        /// <exception cref="NullReferenceException">Thrown if the parameter is <c>null</c>.</exception>
        public static Signalbox ToSignalbox(this SignalboxModel model)
        {
            if (model is null)
            {
                throw new NullReferenceException();
            }

            return(new Signalbox
            {
                Id = model.Id,
                Code = model.Code,
                EditorDisplayName = model.EditorDisplayName,
                ExportDisplayName = model.TimetableDisplayName,
            });
        }