Ejemplo n.º 1
0
        public void Convert_ValidArguments_ExpectedProperties()
        {
            // Setup
            var random            = new Random(21);
            var hydraRingStochast = new HydraRingStochast("hydraRingStochast",
                                                          random.NextDouble(),
                                                          random.NextDouble());

            var hydraRingFaultTreeIllustrationPoint =
                new HydraRingFaultTreeIllustrationPoint("name", random.NextDouble(), new[]
            {
                hydraRingStochast
            }, HydraRingCombinationType.And);

            // Call
            FaultTreeIllustrationPoint faultTreeIllustrationPoint =
                FaultTreeIllustrationPointConverter.Convert(hydraRingFaultTreeIllustrationPoint);

            // Assert
            Assert.AreEqual(hydraRingFaultTreeIllustrationPoint.Beta, faultTreeIllustrationPoint.Beta,
                            faultTreeIllustrationPoint.Beta.GetAccuracy());
            Assert.AreEqual(hydraRingFaultTreeIllustrationPoint.Name, faultTreeIllustrationPoint.Name);
            Assert.AreEqual(CombinationType.And, faultTreeIllustrationPoint.CombinationType);

            Stochast stochast = faultTreeIllustrationPoint.Stochasts.Single();

            Assert.AreEqual(hydraRingStochast.Alpha, stochast.Alpha, stochast.Alpha.GetAccuracy());
            Assert.AreEqual(hydraRingStochast.Duration, stochast.Duration, stochast.Duration.GetAccuracy());
            Assert.AreEqual(hydraRingStochast.Name, stochast.Name);
        }
Ejemplo n.º 2
0
        public void Convert_HydraRingFaultTreeIllustrationPointNull_ThrowsArgumentNullException()
        {
            // Call
            TestDelegate call = () => FaultTreeIllustrationPointConverter.Convert(null);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(call).ParamName;

            Assert.AreEqual("hydraRingFaultTreeIllustrationPoint", paramName);
        }
Ejemplo n.º 3
0
        public void Convert_InvalidHydraRingCombinationType_ThrowsIllustrationPointConversionException()
        {
            // Setup
            var hydraRingFaultTreeIllustrationPoint = new HydraRingFaultTreeIllustrationPoint(
                "name",
                new Random(210).NextDouble(),
                Enumerable.Empty <HydraRingStochast>(),
                (HydraRingCombinationType)999999);

            // Call
            TestDelegate call = () => FaultTreeIllustrationPointConverter.Convert(hydraRingFaultTreeIllustrationPoint);

            // Assert
            var    exception       = Assert.Throws <IllustrationPointConversionException>(call);
            string expectedMessage = $"Could not convert the {typeof(HydraRingCombinationType)} into a {typeof(CombinationType)}.";

            Assert.AreEqual(expectedMessage, exception.Message);
            Assert.IsInstanceOf <InvalidEnumArgumentException>(exception.InnerException);
        }