コード例 #1
0
        public void Transform_StochasticSoilProfileNull_ThrowsArgumentNullException()
        {
            // Setup
            PipingSoilProfile soilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();

            // Call
            TestDelegate test = () => PipingStochasticSoilProfileTransformer.Transform(null, soilProfile);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(test);

            Assert.AreEqual("stochasticSoilProfile", exception.ParamName);
        }
コード例 #2
0
        public void Transform_PipingSoilProfileNull_ThrowsArgumentNullException()
        {
            // Setup
            var mockRepository = new MockRepository();
            var soilProfile    = mockRepository.Stub <ISoilProfile>();

            mockRepository.ReplayAll();

            StochasticSoilProfile stochasticSoilProfile = StochasticSoilProfileTestFactory.CreateStochasticSoilProfileWithValidProbability(soilProfile);

            // Call
            TestDelegate test = () => PipingStochasticSoilProfileTransformer.Transform(stochasticSoilProfile, null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(test);

            Assert.AreEqual("soilProfile", exception.ParamName);
            mockRepository.VerifyAll();
        }
コード例 #3
0
        public void Transform_ValidStochasticSoilProfile_ReturnsExpectedPipingStochasticSoilProfile()
        {
            // Setup
            var random = new Random(21);

            var mockRepository = new MockRepository();
            var soilProfile    = mockRepository.Stub <ISoilProfile>();

            mockRepository.ReplayAll();

            PipingSoilProfile pipingSoilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();

            var stochasticSoilProfile = new StochasticSoilProfile(random.NextDouble(), soilProfile);

            // Call
            PipingStochasticSoilProfile pipingStochasticSoilProfile = PipingStochasticSoilProfileTransformer.Transform(stochasticSoilProfile, pipingSoilProfile);

            // Assert
            Assert.AreEqual(stochasticSoilProfile.Probability, pipingStochasticSoilProfile.Probability);
            Assert.AreSame(pipingSoilProfile, pipingStochasticSoilProfile.SoilProfile);
            mockRepository.VerifyAll();
        }
コード例 #4
0
        public void Transform_InvalidStochasticSoilProfile_ThrowsImportedDataTransformException()
        {
            // Setup
            var mocks       = new MockRepository();
            var soilProfile = mocks.Stub <ISoilProfile>();

            mocks.ReplayAll();

            PipingSoilProfile pipingSoilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();

            var stochasticSoilProfile = new StochasticSoilProfile(double.NaN, soilProfile);

            // Call
            TestDelegate call = () => PipingStochasticSoilProfileTransformer.Transform(stochasticSoilProfile, pipingSoilProfile);

            // Assert
            var exception = Assert.Throws <ImportedDataTransformException>(call);

            Exception innerException = exception.InnerException;

            Assert.IsInstanceOf <ArgumentException>(innerException);
            Assert.AreEqual(innerException.Message, exception.Message);
        }