Beispiel #1
0
        internal void Transform_CorrectlyTransformsThePCoefficient_Test(
            [Frozen] Mock <IPolesCoefficientsFactory> polesCoefficientsFactory, Mock <IAnalog> analog,
            IPolesCoefficients polesCoefficients, double cutoff, LowPassTransformer lowPassTransformer)
        {
            var expected = polesCoefficients.P.Multiply(cutoff).ToList();

            analog.SetupGet(mock => mock.Coefficients).Returns(polesCoefficients);

            lowPassTransformer.Transform(analog.Object, cutoff);

            polesCoefficientsFactory.Verify(
                mock => mock.Build(It.IsAny <double>(), expected, It.IsAny <IReadOnlyList <Complex> >()), Times.Once);
        }
Beispiel #2
0
        internal void Transform_ReturnsTheResultOfThePolesFactory_Test(
            [Frozen] Mock <IPolesCoefficientsFactory> polesCoefficientsFactory, IAnalog analog,
            double cutoff, IPolesCoefficients expected, LowPassTransformer lowPassTransformer)
        {
            polesCoefficientsFactory.Setup(
                mock =>
                mock.Build(It.IsAny <double>(), It.IsAny <IReadOnlyList <Complex> >(),
                           It.IsAny <IReadOnlyList <Complex> >())).Returns(expected);

            var actual = lowPassTransformer.Transform(analog, cutoff);

            Assert.Equal(expected, actual);
        }
Beispiel #3
0
        protected BaseFilterDesign(FilterType filterType)
        {
            this.filterType = filterType;
            this.polesCoefficientsFactory = new PolesCoefficientsFactory();

            ITransformer transformer;

            if (filterType == FilterType.Highpass)
            {
                transformer = new HighpassTransformer(this.polesCoefficientsFactory);
            }
            else
            {
                transformer = new LowPassTransformer(this.polesCoefficientsFactory);
            }

            this.iirProvider =
                new IirProvider(
                    new DigitalPolesProvider(transformer, new DigitalTransformer(polesCoefficientsFactory)),
                    new PolynomialTransformer(new PolynomialCoefficientsFactory()));
        }