public void SignalboxHoursSetModelExtensionsClass_ToSignalboxHoursSetMethod_ThrowsArgumentNullException_IfFirstParameterIsNull()
        {
            SignalboxHoursSetModel          testObject = null;
            IDictionary <string, Signalbox> testParam1 = new Dictionary <string, Signalbox>();
            IEnumerable <SignalboxHoursSet> testParam2 = Array.Empty <SignalboxHoursSet>();

            _ = testObject.ToSignalboxHoursSet(testParam1, testParam2);

            Assert.Fail();
        }
Exemple #2
0
        public void SignalboxHoursSetModelExtensionsClass_ToSignalboxHoursSetMethod_ReturnsObjectWithHoursPropertyContainingCorrectNumberOfElements()
        {
            SignalboxHoursSetModel          testParam0 = GetTestObject();
            IDictionary <string, Signalbox> testParam1 = GetSignalboxCollectionWithItems(testParam0.Signalboxes.Select(s => s.SignalboxId));
            IEnumerable <SignalboxHoursSet> testParam2 = GetExistingSets();

            SignalboxHoursSet testOutput = testParam0.ToSignalboxHoursSet(testParam1, testParam2);

            Assert.AreEqual(testParam0.Signalboxes.Count, testOutput.Hours.Count);
        }
Exemple #3
0
        public void SignalboxHoursSetModelExtensionsClass_ToSignalboxHoursSetMethod_ReturnsObjectWithCorrectCategoryProperty()
        {
            SignalboxHoursSetModel          testParam0 = GetTestObject();
            IDictionary <string, Signalbox> testParam1 = GetSignalboxCollectionWithItems(testParam0.Signalboxes.Select(s => s.SignalboxId));
            IEnumerable <SignalboxHoursSet> testParam2 = GetExistingSets();

            SignalboxHoursSet testOutput = testParam0.ToSignalboxHoursSet(testParam1, testParam2);

            Assert.AreEqual(testParam0.Category, testOutput.Category);
        }
Exemple #4
0
        public void SignalboxHoursSetModelExtensionsClass_ToSignalboxHoursSetMethod_ReturnsObjectWithIdPropertyThatDiffersFromIdsOfContentsOfThirdParameter()
        {
            SignalboxHoursSetModel          testParam0 = GetTestObject();
            IDictionary <string, Signalbox> testParam1 = GetSignalboxCollectionWithItems(testParam0.Signalboxes.Select(s => s.SignalboxId));
            IEnumerable <SignalboxHoursSet> testParam2 = GetExistingSets();

            SignalboxHoursSet testOutput = testParam0.ToSignalboxHoursSet(testParam1, testParam2);

            Assert.IsFalse(testParam2.Any(s => s.Id == testOutput.Id));
        }
Exemple #5
0
        public void SignalboxHoursSetModelExtensionsClass_ToSignalboxHoursSetMethod_ThrowsArgumentNullException_IfSecondParameterIsNull()
        {
            SignalboxHoursSetModel          testParam0 = GetTestObject();
            IDictionary <string, Signalbox> testParam1 = null;
            IEnumerable <SignalboxHoursSet> testParam2 = new List <SignalboxHoursSet>();

            _ = testParam0.ToSignalboxHoursSet(testParam1, testParam2);

            Assert.Fail();
        }
Exemple #6
0
        public void SignalboxHoursSetModelExtensionsClass_ToSignalboxHoursSetMethod_ThrowsNullReferenceException_IfFirstParameterIsNull()
        {
            SignalboxHoursSetModel          testParam0 = null;
            IDictionary <string, Signalbox> testParam1 = new Dictionary <string, Signalbox>();
            IEnumerable <SignalboxHoursSet> testParam2 = new List <SignalboxHoursSet>();

            _ = testParam0.ToSignalboxHoursSet(testParam1, testParam2);

            Assert.Fail();
        }
Exemple #7
0
        public void SignalboxHoursSetModelExtensionsClass_ToSignalboxHoursSetMethod_ReturnsObjectWithHoursPropertyContainingElementsWithCorrectSignalboxProperties()
        {
            SignalboxHoursSetModel          testParam0 = GetTestObject();
            IDictionary <string, Signalbox> testParam1 = GetSignalboxCollectionWithItems(testParam0.Signalboxes.Select(s => s.SignalboxId));
            IEnumerable <SignalboxHoursSet> testParam2 = GetExistingSets();

            SignalboxHoursSet testOutput = testParam0.ToSignalboxHoursSet(testParam1, testParam2);

            foreach (string id in testParam0.Signalboxes.Select(s => s.SignalboxId))
            {
                Assert.AreSame(testParam1[id], testOutput.Hours[id].Signalbox);
            }
        }
Exemple #8
0
        public void SignalboxHoursSetModelExtensionsClass_ToSignalboxHoursSetMethod_ReturnsObjectWithHoursPropertyContainingCorrectlyIndexedElements()
        {
            SignalboxHoursSetModel          testParam0 = GetTestObject();
            IDictionary <string, Signalbox> testParam1 = GetSignalboxCollectionWithItems(testParam0.Signalboxes.Select(s => s.SignalboxId));
            IEnumerable <SignalboxHoursSet> testParam2 = GetExistingSets();

            SignalboxHoursSet testOutput = testParam0.ToSignalboxHoursSet(testParam1, testParam2);

            foreach (KeyValuePair <string, SignalboxHours> item in testOutput.Hours)
            {
                Assert.AreEqual(item.Key, item.Value.Signalbox.Id);
            }
        }
Exemple #9
0
        public void SignalboxHoursSetModelExtensionsClass_ToSignalboxHoursSetMethod_ThrowsFormatException_IfFirstParameterHasSignalboxesPropertyContainingElementsWithFinishTimePropertyThatHaveTimePropertyThatIsNotNumeric()
        {
            SignalboxHoursSetModel          testParam0 = GetTestObject();
            IDictionary <string, Signalbox> testParam1 = GetSignalboxCollectionWithItems(testParam0.Signalboxes.Select(s => s.SignalboxId));
            IEnumerable <SignalboxHoursSet> testParam2 = GetExistingSets();

            foreach (SignalboxHoursModel box in testParam0.Signalboxes)
            {
                box.FinishTime = new TimeOfDaySpecification(TimeOfDaySpecification.TimeOfDaySpecificationKind.NonNumericValue).Model;
            }

            _ = testParam0.ToSignalboxHoursSet(testParam1, testParam2);

            Assert.Fail();
        }
Exemple #10
0
        public void SignalboxHoursSetModelExtensionsClass_ToSignalboxHoursSetMethod_ThrowsNullReferenceException_IfFirstParameterHasSignalboxesPropertyContainingElementsWithFinishTimePropertyThatIsNull()
        {
            SignalboxHoursSetModel          testParam0 = GetTestObject();
            IDictionary <string, Signalbox> testParam1 = GetSignalboxCollectionWithItems(testParam0.Signalboxes.Select(s => s.SignalboxId));
            IEnumerable <SignalboxHoursSet> testParam2 = GetExistingSets();

            foreach (SignalboxHoursModel box in testParam0.Signalboxes)
            {
                box.FinishTime = null;
            }

            _ = testParam0.ToSignalboxHoursSet(testParam1, testParam2);

            Assert.Fail();
        }
        public void SignalboxHoursSetModelExtensionsClass_ToSignalboxHoursSetMethod_ThrowsArgumentNullExceptionWithCorrectParamNameProperty_IfFirstParameterIsNull()
        {
            SignalboxHoursSetModel          testObject = null;
            IDictionary <string, Signalbox> testParam1 = new Dictionary <string, Signalbox>();
            IEnumerable <SignalboxHoursSet> testParam2 = Array.Empty <SignalboxHoursSet>();

            try
            {
                _ = testObject.ToSignalboxHoursSet(testParam1, testParam2);
                Assert.Fail();
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("model", ex.ParamName);
            }
        }
Exemple #12
0
        public void SignalboxHoursSetModelExtensionsClass_ToSignalboxHoursSetMethod_ReturnsObjectWithHoursPropertyContainingElementsWithCorrectTokenBalanceWarningProperty()
        {
            SignalboxHoursSetModel          testParam0 = GetTestObject();
            IDictionary <string, Signalbox> testParam1 = GetSignalboxCollectionWithItems(testParam0.Signalboxes.Select(s => s.SignalboxId));
            IEnumerable <SignalboxHoursSet> testParam2 = GetExistingSets();
            Dictionary <string, bool?>      tokenBalanceWarningFlags = new Dictionary <string, bool?>();

            foreach (SignalboxHoursModel box in testParam0.Signalboxes)
            {
                tokenBalanceWarningFlags.Add(box.SignalboxId, box.TokenBalanceWarning);
            }

            SignalboxHoursSet testOutput = testParam0.ToSignalboxHoursSet(testParam1, testParam2);

            foreach (string id in testParam0.Signalboxes.Select(s => s.SignalboxId))
            {
                Assert.AreEqual(tokenBalanceWarningFlags[id] ?? false, testOutput.Hours[id].TokenBalanceWarning);
            }
        }
Exemple #13
0
        public void SignalboxHoursSetModelExtensionsClass_ToSignalboxHoursSetMethod_ReturnsObjectWithHoursPropertyContainingElementsWithCorrectEndTimeProperty_IfFirstParameterHasSignalboxesPropertyContainingElementsWithFinishTimePropertiesThatHaveTimePropertyThatIsMoreThanThreeNumbersWithinRangeSeparatedByColons()
        {
            SignalboxHoursSetModel                      testParam0 = GetTestObject();
            IDictionary <string, Signalbox>             testParam1 = GetSignalboxCollectionWithItems(testParam0.Signalboxes.Select(s => s.SignalboxId));
            IEnumerable <SignalboxHoursSet>             testParam2 = GetExistingSets();
            Dictionary <string, TimeOfDaySpecification> timeSpecs  = new Dictionary <string, TimeOfDaySpecification>();

            foreach (SignalboxHoursModel box in testParam0.Signalboxes)
            {
                TimeOfDaySpecification timeSpec = new TimeOfDaySpecification(TimeOfDaySpecification.TimeOfDaySpecificationKind.HoursMinutesSecondsAndMore);
                box.FinishTime = timeSpec.Model;
                timeSpecs.Add(box.SignalboxId, timeSpec);
            }

            SignalboxHoursSet testOutput = testParam0.ToSignalboxHoursSet(testParam1, testParam2);

            foreach (string id in testParam0.Signalboxes.Select(s => s.SignalboxId))
            {
                Assert.AreEqual(timeSpecs[id].Hours.Value, testOutput.Hours[id].EndTime.Hours24);
                Assert.AreEqual(timeSpecs[id].Minutes.Value, testOutput.Hours[id].EndTime.Minutes);
                Assert.AreEqual(timeSpecs[id].Seconds.Value, testOutput.Hours[id].EndTime.Seconds);
            }
        }