コード例 #1
0
 public void Constructor_NegativeGammaThrowsArgumentOutOfRangeException()
 {
     // Assert
     Assert.Throws <ArgumentOutOfRangeException>(() => {
         // Act
         var effect = new GammaEffect(-1d);
     });
 }
コード例 #2
0
        public void Constructor_InitializesExpectedProperties()
        {
            // Act
            var effect = new GammaEffect(0.5d);

            // Assert
            Assert.Equal(0.5d, effect.Gamma);
        }
コード例 #3
0
        public void ISerializable_DeserializeNegativeGammaThrowsException()
        {
            // Arrange
            var info = MockSerializationInfo <GammaEffect>();

            info.AddValue("Gamma", -1d);

            // Act
            Assert.Throws <ArgumentOutOfRangeException>(() => {
                var actual = new GammaEffect(info, new StreamingContext());
            });
        }
コード例 #4
0
        public void ISerializable_SerializeAndDeserializeCorrectly()
        {
            // Arrange
            var expected = new GammaEffect(0.5d);
            var info     = MockSerializationInfo <GammaEffect>();

            // Act
            expected.GetObjectData(info, new StreamingContext());
            var actual = new GammaEffect(info, new StreamingContext());

            // Assert
            Assert.Equal(expected.Gamma, actual.Gamma);
        }
コード例 #5
0
        public void Calculate_AppliesEffectOnHeightMap(double gamma)
        {
            // Arrange
            var data = new double[, ] {
                { 0d, 0.25d, 0.5d, 0.75d, 1d }
            };
            var heightMap = new HeightMap(data);
            var expected  = MockImageEffect(heightMap, gamma);
            var effect    = new GammaEffect(gamma);

            // Act
            var actual = effect.Calculate(heightMap).Data;

            // Assert
            Assert.Equal(expected[0, 0], actual[0, 0]);
            Assert.Equal(expected[0, 1], actual[0, 1]);
            Assert.Equal(expected[0, 2], actual[0, 2]);
            Assert.Equal(expected[0, 3], actual[0, 3]);
            Assert.Equal(expected[0, 4], actual[0, 4]);
        }