Exemplo n.º 1
0
        public void Should_throw_if_negative_sample_rate_specified()
        {
            var target = new DigitalFilter();

            target.FilterFunction = Substitute.For <IFilterFunction>();

            target.CalculateCoefficients(1, -2);
        }
Exemplo n.º 2
0
        public void Should_throw_if_filter_function_is_null_when_calculating_coefficients()
        {
            var target = new DigitalFilter();

            target.FilterFunction = null;

            target.CalculateCoefficients(1, 2);
        }
Exemplo n.º 3
0
        public void Should_correctly_pass_parameters_to_filter_function()
        {
            var target = new DigitalFilter();

            target.FilterFunction = Substitute.For <IFilterFunction>();

            target.LowerCutOffFrequency = 2f;
            target.UpperCutOffFrequency = 5f;

            target.CalculateCoefficients(1, 3);

            target.FilterFunction.Received(1).CalculateCoefficients(1, 2f, 5f, 3);
        }
Exemplo n.º 4
0
        public void Should_return_the_result_of_filter_function()
        {
            var target = new DigitalFilter();

            var expected = new float[] { 1f, 2f, 3f, 4f, 5f };

            target.FilterFunction = Substitute.For <IFilterFunction>();
            target.FilterFunction.CalculateCoefficients(
                Arg.Any <int>(),
                Arg.Any <float>(),
                Arg.Any <float>(),
                Arg.Any <int>()).Returns(expected);

            target.LowerCutOffFrequency = 2f;
            target.UpperCutOffFrequency = 5f;

            var actual = target.CalculateCoefficients(1, 3);

            CollectionAssert.AreEqual(expected, actual, new FloatComparer());
        }