Here are the examples of the csharp api NUnit.Framework.Assert.Multiple(NUnit.Framework.AsyncTestDelegate) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
89 Examples
19
Source : TestFeaturePostProcessing.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestMeanNormalization()
{
FeaturePostProcessing.NormalizeMean(_feats);
replacedert.Multiple(() =>
{
replacedert.That(_feats[0], Is.EqualTo(new float[] { 0.8f, 0, -1, 1.6f, 2 }).Within(1e-5));
replacedert.That(_feats[1], Is.EqualTo(new float[] { -0.2f, 0, 0, -2.4f, 1 }).Within(1e-5));
replacedert.That(_feats[2], Is.EqualTo(new float[] { -0.2f, 0, 2, 1.6f, 0 }).Within(1e-5));
replacedert.That(_feats[3], Is.EqualTo(new float[] { -0.2f, 0, 0, -2.4f, -1 }).Within(1e-5));
replacedert.That(_feats[4], Is.EqualTo(new float[] { -0.2f, 0, -1, 1.6f, -2 }).Within(1e-5));
});
}
19
Source : TestFeaturePostProcessing.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestVarianceNormalization()
{
FeaturePostProcessing.NormalizeVariance(_feats, bias: 0);
replacedert.Multiple(() =>
{
replacedert.That(_feats[0], Is.EqualTo(new float[] { 2.5f, 2, 2.74f, 2.04f, 3.536f }).Within(1e-2));
replacedert.That(_feats[1], Is.EqualTo(new float[] { 0, 2, 3.65f, 0, 2.83f }).Within(1e-2));
replacedert.That(_feats[2], Is.EqualTo(new float[] { 0, 2, 5.48f, 2.04f, 2.12f }).Within(1e-2));
replacedert.That(_feats[3], Is.EqualTo(new float[] { 0, 2, 3.65f, 0, 1.41f }).Within(1e-2));
replacedert.That(_feats[4], Is.EqualTo(new float[] { 0, 2, 2.74f, 2.04f, 0.71f }).Within(1e-2));
});
}
19
Source : TestIirFilter.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
private static void replacedertFilterOutput(DiscreteSignal output)
{
replacedert.Multiple(() =>
{
replacedert.That(output[0], Is.EqualTo(1.0).Within(1e-7));
replacedert.That(output[1], Is.EqualTo(1.0).Within(1e-7));
replacedert.That(output[2], Is.EqualTo(0.4).Within(1e-7));
replacedert.That(output[3], Is.EqualTo(0.04).Within(1e-7));
});
}
19
Source : TestTransferFunction.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestParallelFirFir()
{
var f1 = new FirFilter(new[] { 1, -0.1 });
var f2 = new FirFilter(new[] { 1, -0.6 });
var f = f1 + f2;
replacedert.Multiple(() =>
{
replacedert.That(f.Tf.Numerator, Is.EqualTo(new[] { 2, -0.7 }).Within(1e-7));
replacedert.That(f, Is.TypeOf<FirFilter>());
});
}
19
Source : TestTransferFunction.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestSequentialIirFir()
{
var f1 = new IirFilter(new[] { 1, -0.1 }, new[] { 1, 0.2 });
var f2 = new FirFilter(new[] { 1, 0.4 });
var f = f1 * f2;
replacedert.Multiple(() =>
{
replacedert.That(f.Tf.Numerator, Is.EqualTo(new[] { 1, 0.3, -0.04 }).Within(1e-7));
replacedert.That(f.Tf.Denominator, Is.EqualTo(new[] { 1, 0.2 }).Within(1e-7));
replacedert.That(f, Is.TypeOf<IirFilter>());
});
}
19
Source : TestTransferFunction.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestSequentialFirIir()
{
var f1 = new FirFilter(new[] { 1, 0.4 });
var f2 = new IirFilter(new[] { 1, -0.1 }, new[] { 1, 0.2 });
var f = f1 * f2;
replacedert.Multiple(() =>
{
replacedert.That(f.Tf.Numerator, Is.EqualTo(new[] { 1, 0.3, -0.04 }).Within(1e-7));
replacedert.That(f.Tf.Denominator, Is.EqualTo(new[] { 1, 0.2 }).Within(1e-7));
replacedert.That(f, Is.TypeOf<IirFilter>());
});
}
19
Source : TestTransferFunction.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestTfToSos()
{
var zeros = new Complex[6]
{
new Complex(1, 0),
new Complex(0.5, 0.2),
new Complex(-0.3, 0),
new Complex(0.2, -0.9),
new Complex(0.5, -0.2),
new Complex(0.2, 0.9)
};
var poles = new Complex[7]
{
new Complex(1, 0),
new Complex(0.2, 0),
new Complex(0.5, 0),
new Complex(-0.9, 0.2),
new Complex(0.6, 0),
new Complex(0.1, 0),
new Complex(-0.9, -0.2)
};
var sos = DesignFilter.TfToSos(new TransferFunction(zeros, poles));
replacedert.Multiple(() =>
{
replacedert.That(sos[0].Numerator, Is.EqualTo(new[] { 1, -0.4, 0.85 }).Within(1e-10));
replacedert.That(sos[0].Denominator, Is.EqualTo(new[] { 1, -0.1, 0 }).Within(1e-10));
replacedert.That(sos[1].Numerator, Is.EqualTo(new[] { 1, -1, 0.29 }).Within(1e-10));
replacedert.That(sos[1].Denominator, Is.EqualTo(new[] { 1, -0.7, 0.1 }).Within(1e-10));
replacedert.That(sos[2].Numerator, Is.EqualTo(new[] { 1, 0.3, 0 }).Within(1e-10));
replacedert.That(sos[2].Denominator, Is.EqualTo(new[] { 1, 1.8, 0.85 }).Within(1e-10));
replacedert.That(sos[3].Numerator, Is.EqualTo(new[] { 1, -1, 0 }).Within(1e-10));
replacedert.That(sos[3].Denominator, Is.EqualTo(new[] { 1, -1.6, 0.6 }).Within(1e-10));
replacedert.That(sos.Length, Is.EqualTo(4));
});
}
19
Source : TestSignalBuilders.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestBuilderDelay()
{
var sinusoid = new SineBuilder()
.SetParameter("freq", 0.05f)
.OfLength(20)
.DelayedBy(1)
.Build();
replacedert.Multiple(() =>
{
replacedert.That(sinusoid[1], Is.EqualTo(0.0).Within(1e-7));
replacedert.That(sinusoid[6], Is.EqualTo(1.0).Within(1e-7));
replacedert.That(sinusoid[16], Is.EqualTo(-1.0).Within(1e-7));
replacedert.That(sinusoid.Length, Is.EqualTo(21));
});
}
19
Source : TestMedianFilter.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestMedianFilteringDefault()
{
var filter1 = new MedianFilter(); // 9-point median filter (faster implementation for sizes > 10)
var filter2 = new MedianFilter2(); // 9-point median filter
var input = new[] { 1, 6, 5, 2, 8, 1, 9, 5, 4, 2, 3, 4, 6, 7, 4f };
var expected = new[] { 1, 1, 2, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 3, 3f };
var filtered1 = filter1.ApplyTo(new DiscreteSignal(1, input));
var filtered2 = filter2.ApplyTo(new DiscreteSignal(1, input));
replacedert.Multiple(() =>
{
replacedert.That(filtered1.Samples, Is.EqualTo(expected).Within(1e-10));
replacedert.That(filtered2.Samples, Is.EqualTo(expected).Within(1e-10));
});
}
19
Source : TestTransferFunction.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestParallelIirIir()
{
var f1 = new IirFilter(new[] { 1, -0.1 }, new[] { 1, 0.2 });
var f2 = new IirFilter(new[] { 1, 0.4 }, new[] { 1, -0.6 });
var f = f1 + f2;
replacedert.Multiple(() =>
{
replacedert.That(f.Tf.Numerator, Is.EqualTo(new[] { 2, -0.1, 0.14 }).Within(1e-7));
replacedert.That(f.Tf.Denominator, Is.EqualTo(new[] { 1, -0.4, -0.12 }).Within(1e-7));
});
}
19
Source : TestTransferFunction.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestParallelIirFir()
{
var f1 = new IirFilter(new[] { 1, 0.4 }, new[] { 1, -0.6 });
var f2 = new FirFilter(new[] { 1, -0.1 });
var f = f1 + f2;
replacedert.Multiple(() =>
{
replacedert.That(f.Tf.Numerator, Is.EqualTo(new[] { 2, -0.3, 0.06 }).Within(1e-7));
replacedert.That(f.Tf.Denominator, Is.EqualTo(new[] { 1, -0.6 }).Within(1e-7));
replacedert.That(f, Is.TypeOf<IirFilter>());
});
}
19
Source : TestTransferFunction.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestStateSpaceToTf()
{
var tf = new TransferFunction(new[] { 1, 0.7, -0.2, 0.1 }, new[] { 1, 0.5, 0.9, 0.6 });
var ss = tf.StateSpace;
var tfs = new TransferFunction(ss);
replacedert.Multiple(() =>
{
replacedert.That(tf.Numerator, Is.EqualTo(tf.Numerator).Within(1e-10));
replacedert.That(tf.Denominator, Is.EqualTo(tf.Denominator).Within(1e-10));
});
}
19
Source : TestConvolution.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestImaginaryParts()
{
var s1 = new ComplexDiscreteSignal(1, new[] { 1, 0.5 }, new[] { 0, -1.5 });
var s2 = new ComplexDiscreteSignal(1, new[] { 1, 0.5 }, new[] { 0, 1.5 });
var conv = Operation.Convolve(s1, s2);
replacedert.Multiple(() =>
{
replacedert.That(conv.Real, Is.EquivalentTo(new[] {1, 1, 2.5}));
replacedert.That(conv.Imag, Is.EqualTo(new[] {0, 0, 0}).Within(1e-6));
});
}
19
Source : TestResampling.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestSameSamplingRate()
{
var signal = new DiscreteSignal(16000, new [] {1.0f, -2, 3, 1, 4, -2, 1, -5, 3});
var resampled = Operation.Resample(signal, 16000);
replacedert.Multiple(() =>
{
replacedert.That(resampled.Samples, Is.EqualTo(resampled.Samples).Within(1e-10));
replacedert.That(resampled, Is.Not.SameAs(signal));
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestInitializeWithBadSamplingRate()
{
replacedert.Multiple(() =>
{
replacedert.Throws<ArgumentException>(() => { var s = new ComplexDiscreteSignal(0, new double[] {1}); });
replacedert.Throws<ArgumentException>(() => { var s = new ComplexDiscreteSignal(-8000, new double[] {1}); });
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestPositiveDelay()
{
//Act
var delayed = _signal.Delay(3);
//replacedert
replacedert.Multiple(() =>
{
replacedert.That(delayed.Real, Is.EqualTo(new double[] {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}));
replacedert.That(delayed.Imag, Is.EqualTo(new double[] {0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0}));
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestNegativeDelay()
{
//Act
var delayed = _signal.Delay(-3);
//replacedert
replacedert.Multiple(() =>
{
replacedert.That(delayed.Real, Is.EqualTo(new double[] {3, 4, 5, 6, 7, 8, 9}));
replacedert.That(delayed.Imag, Is.EqualTo(new double[] {0, 0, 1, 0, 0, 1, 0}));
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestSuperimposeBroadcastArgument()
{
//Act
var combination = _signal.Superimpose(_constant);
//replacedert
replacedert.Multiple(() =>
{
replacedert.That(combination.Real, Is.EqualTo(new double[] {5, 6, 7, 8, 9, 5, 6, 7, 8, 9}));
replacedert.That(combination.Imag, Is.EqualTo(new double[] {1, 1, 2, 1, 1, 1, 0, 0, 1, 0}));
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestSuperimposeBroadcastObject()
{
//Act
var combination1 = _constant.Superimpose(_signal);
var combination2 = _constant + _signal;
//replacedert
replacedert.Multiple(() =>
{
replacedert.That(combination1.Real, Is.EqualTo(new double[] {5, 6, 7, 8, 9, 5, 6, 7, 8, 9}));
replacedert.That(combination1.Imag, Is.EqualTo(new double[] {1, 1, 2, 1, 1, 1, 0, 0, 1, 0}));
replacedert.That(combination2.Real, Is.EqualTo(new double[] {5, 6, 7, 8, 9, 5, 6, 7, 8, 9}));
replacedert.That(combination2.Imag, Is.EqualTo(new double[] {1, 1, 2, 1, 1, 1, 0, 0, 1, 0}));
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestConcatenate()
{
//Act
var concatenation = _signal.Concatenate(_constant);
//replacedert
replacedert.Multiple(() =>
{
replacedert.That(concatenation.Real, Is.EqualTo(new double[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 5, 5, 5, 5}));
replacedert.That(concatenation.Imag, Is.EqualTo(new double[] {0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1}));
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestRepeat()
{
//Act
var repeated = _small.Repeat(3);
//replacedert
replacedert.Multiple(() =>
{
replacedert.That(repeated.Real, Is.EqualTo(new double[] {5, 2, 4, 5, 2, 4, 5, 2, 4}));
replacedert.That(repeated.Imag, Is.EqualTo(new double[] {3, 0, 8, 3, 0, 8, 3, 0, 8}));
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestAmplification()
{
//Act
var amplified = _small * 2;
//replacedert
replacedert.Multiple(() =>
{
replacedert.That(amplified.Real, Is.EqualTo(new float[] {10, 4, 8}));
replacedert.That(amplified.Imag, Is.EqualTo(new float[] {6, 0, 16}));
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestSlice()
{
// Act
var slice = _signal[3, 7];
// replacedert
replacedert.Multiple(() =>
{
replacedert.That(slice.Real, Is.EqualTo(new double[] {3, 4, 5, 6}));
replacedert.That(slice.Imag, Is.EqualTo(new double[] {0, 0, 1, 0}));
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestSliceWrongRange()
{
replacedert.Multiple(() =>
{
replacedert.Throws<ArgumentException>(() => { var slice = _signal[5, 5]; });
replacedert.Throws<ArgumentException>(() => { var slice = _signal[5, 4]; });
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestFirstSamples()
{
// Act
var first = _signal.First(3);
// replacedert
replacedert.Multiple(() =>
{
replacedert.That(first.Real, Is.EqualTo(new double[] {0, 1, 2}));
replacedert.That(first.Imag, Is.EqualTo(new double[] {0, 0, 1}));
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestLastSamples()
{
// Act
var last = _signal.Last(3);
// replacedert
replacedert.Multiple(() =>
{
replacedert.That(last.Real, Is.EqualTo(new double[] {7, 8, 9}));
replacedert.That(last.Imag, Is.EqualTo(new double[] {0, 1, 0}));
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestNegativeFirstOrLast()
{
replacedert.Multiple(() =>
{
replacedert.Throws<ArgumentException>(() => { var first = _signal.First(-3); });
replacedert.Throws<ArgumentException>(() => { var last = _signal.Last(-5); });
});
}
19
Source : TestDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestSuperimposeBroadcastArgument()
{
//Act
var combination1 = _signal.Superimpose(_constant);
var combination2 = _constant + _signal;
//replacedert
replacedert.Multiple(() =>
{
replacedert.That(combination1.Samples, Is.EqualTo(new float[] {5, 6, 7, 8, 9, 5, 6, 7, 8, 9}));
replacedert.That(combination2.Samples, Is.EqualTo(new float[] {5, 6, 7, 8, 9, 5, 6, 7, 8, 9}));
});
}
19
Source : TestDct.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestMdct()
{
float[] res = new float[4];
float[] fres = new float[4];
float[] resMdct = { -0.38134489f, -0.01107969f, 0.27565625f, 0.09201603f };
var mdct = new Mdct(4);
var fmdct = new FastMdct(4);
mdct.DirectNorm(_test, res);
fmdct.DirectNorm(_test, fres);
replacedert.Multiple(() =>
{
replacedert.That(res, Is.EqualTo(resMdct).Within(1e-5));
replacedert.That(fres, Is.EqualTo(resMdct).Within(1e-5));
});
}
19
Source : TestDct.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestImdct()
{
float[] res = new float[8];
float[] fres = new float[8];
float[] resMdct = { -0.38134489f, -0.01107969f, 0.27565625f, 0.09201603f };
var mdct = new Mdct(4);
var fmdct = new FastMdct(4);
mdct.InverseNorm(resMdct, res);
fmdct.InverseNorm(resMdct, fres);
replacedert.Multiple(() =>
{
replacedert.That(res, Is.EqualTo(new[] { -0.05f, 0.05f, -0.05f, 0.05f, 0.45f, 0.15f, 0.15f, 0.45f }).Within(1e-5));
replacedert.That(fres, Is.EqualTo(res).Within(1e-5));
});
}
19
Source : TestFft.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestInverseRealFft()
{
float[] array = { 1, 5, 3, 7, 2, 3, 0, 7 };
float[] output = new float[array.Length];
float[] outputNorm = new float[array.Length];
float[] re = new float[5];
float[] im = new float[5];
var realFft = new RealFft(8);
realFft.Direct(array, re, im);
realFft.Inverse(re, im, output);
realFft.InverseNorm(re, im, outputNorm);
replacedert.Multiple(() =>
{
replacedert.That(output, Is.EqualTo(array.Select(a => a * 8)).Within(1e-5));
replacedert.That(outputNorm, Is.EqualTo(array).Within(1e-5));
});
}
19
Source : TestFft.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestGoertzel()
{
float[] array = { 1, 2, 3, 4, 5, 6, 7, 8 };
var cmpx = new Goertzel(8).Direct(array, 2);
replacedert.Multiple(() =>
{
replacedert.That(cmpx.Real, Is.EqualTo(-4).Within(1e-6));
replacedert.That(cmpx.Imaginary, Is.EqualTo(4).Within(1e-6));
});
}
19
Source : TestMathFunctions.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestComplexPolynomialRoots()
{
double[] re = { 1, 1, 2.5 };
var roots = MathUtils.PolynomialRoots(re);
double[] expectedReal = { -0.5, -0.5 };
double[] expectedImag = { -1.5, 1.5 };
replacedert.Multiple(() =>
{
replacedert.That(roots.Select(r => r.Real).OrderBy(r => r), Is.EqualTo(expectedReal).Within(1e-7));
replacedert.That(roots.Select(r => r.Imaginary).OrderBy(r => r), Is.EqualTo(expectedImag).Within(1e-7));
});
}
19
Source : TestMathFunctions.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestPolynomialDivision()
{
Complex[] num = { 2, 4, 6, 1, 2, 3 };
Complex[] den = { 1, 2, 3 };
var div = MathUtils.DividePolynomial(num, den);
replacedert.Multiple(() =>
{
replacedert.That(div[0].Select(d => d.Real), Is.EqualTo(new[] {2.0, 0, 0, 1}).Within(1e-10));
replacedert.That(div[0].Select(d => d.Imaginary), Is.EqualTo(new[] { 0.0, 0, 0, 0 }).Within(1e-10));
replacedert.That(div[1].Select(d => d.Real), Is.All.EqualTo(0.0).Within(1e-10));
});
}
19
Source : TestSignalBuilders.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestBuilderSuperimpose()
{
var constants = new DiscreteSignal(1, length: 6, value: 2.0f);
var sinusoid = new SineBuilder()
.SetParameter("freq", 0.05f)
.SuperimposedWith(constants)
.OfLength(20)
.SuperimposedWith(constants) // twice
.Build();
replacedert.Multiple(() =>
{
replacedert.That(sinusoid[0], Is.EqualTo(4.0).Within(1e-7));
replacedert.That(sinusoid[5], Is.EqualTo(5.0).Within(1e-7));
replacedert.That(sinusoid[10], Is.EqualTo(0.0).Within(1e-7));
replacedert.That(sinusoid[15], Is.EqualTo(-1.0).Within(1e-7));
replacedert.That(sinusoid.Length, Is.EqualTo(20));
});
}
19
Source : TestSignalBuilders.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestBuilderRepeat()
{
var sinusoid = new SineBuilder()
.SetParameter("freq", 0.05f)
.OfLength(20)
.RepeatedTimes(3)
.Build();
replacedert.Multiple(() =>
{
replacedert.That(sinusoid[0], Is.EqualTo(0.0).Within(1e-7));
replacedert.That(sinusoid[5], Is.EqualTo(1.0).Within(1e-7));
replacedert.That(sinusoid[25], Is.EqualTo(1.0).Within(1e-7));
replacedert.That(sinusoid.Length, Is.EqualTo(60));
});
}
19
Source : TestTransferFunction.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestParallelFirIir()
{
var f1 = new FirFilter(new[] { 1, -0.1 });
var f2 = new IirFilter(new[] { 1, 0.4 }, new[] { 1, -0.6 });
var f = f1 + f2;
replacedert.Multiple(() =>
{
replacedert.That(f.Tf.Numerator, Is.EqualTo(new[] { 2, -0.3, 0.06 }).Within(1e-7));
replacedert.That(f.Tf.Denominator, Is.EqualTo(new[] { 1, -0.6 }).Within(1e-7));
replacedert.That(f, Is.TypeOf<IirFilter>());
});
}
19
Source : TestTransferFunction.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestSosToTf()
{
var sos = new TransferFunction[4]
{
new TransferFunction(new[] { 1, -0.4, 0.85 }, new[] { 1, -0.1, 0 }),
new TransferFunction(new[] { 1, -1, 0.29 }, new[] { 1, -0.7, 0.1 }),
new TransferFunction(new[] { 1, 0.3, 0 }, new[] { 1, 1.8, 0.85 }),
new TransferFunction(new[] { 1, -1, 0.0 }, new[] { 1, -1.6, 0.6 })
};
var tf = DesignFilter.SosToTf(sos);
replacedert.Multiple(() =>
{
replacedert.That(tf.Numerator, Is.EqualTo(new[] { 1, -2.1, 2.22, -1.624, 0.4607, 0.11725, -0.07395, 0, 0 }).Within(1e-10));
replacedert.That(tf.Denominator, Is.EqualTo(new[] { 1, -0.6, -1.42, 0.888, 0.4889, -0.4413, 0.0895, -0.0051, 0}).Within(1e-10));
});
}
19
Source : TestTransferFunction.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestTfToStateSpace()
{
var tf = new TransferFunction(new[] { 2, 0.7, -0.2 }, new[] { 1, 0.5, 0.9, 0.6 });
var ss = tf.StateSpace;
replacedert.Multiple(() =>
{
replacedert.That(ss.A[0], Is.EqualTo(new[] { -0.5, -0.9, -0.6 }).Within(1e-10));
replacedert.That(ss.A[1], Is.EqualTo(new[] { 1.0, 0.0, 0.0 }).Within(1e-10));
replacedert.That(ss.A[2], Is.EqualTo(new[] { 0.0, 1.0, 0.0 }).Within(1e-10));
replacedert.That(ss.B, Is.EqualTo(new[] { 1.0, 0.0, 0.0 }).Within(1e-10));
replacedert.That(ss.C, Is.EqualTo(new[] { 2.0, 0.7, -0.2 }).Within(1e-10));
replacedert.That(ss.D, Is.EqualTo(new[] { 0.0 }).Within(1e-10));
});
}
19
Source : TestSignalBuilders.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestSimpleSinusoidBuilder()
{
var sinusoid = new SineBuilder()
.SetParameter("freq", 0.05f)
.OfLength(20)
.Build();
replacedert.Multiple(() =>
{
replacedert.That(sinusoid[0], Is.EqualTo(0.0).Within(1e-7));
replacedert.That(sinusoid[5], Is.EqualTo(1.0).Within(1e-7));
replacedert.That(sinusoid[10], Is.EqualTo(0.0).Within(1e-7));
replacedert.That(sinusoid[15], Is.EqualTo(-1.0).Within(1e-7));
replacedert.That(sinusoid.Length, Is.EqualTo(20));
});
}
19
Source : Happy_path.cs
with MIT License
from ComparetheMarket
with MIT License
from ComparetheMarket
[Test]
public void Console_executable_runs_and_outputs_info_about_surviving_mutants()
{
replacedert.Multiple(() =>
{
replacedert.That(ExitCode, Is.EqualTo(1));
replacedert.That(StandardError, Is.Empty);
replacedert.That(StandardOutput, Does.Contain("mutant(s) survived!"));
replacedert.That(StandardOutput, Does.Contain("PartiallyTestedNumberComparison.cs:7"));
});
}
19
Source : Verbose_mode.cs
with MIT License
from ComparetheMarket
with MIT License
from ComparetheMarket
[Test]
public void Then_detailed_mutation_testing_progress_is_output()
{
replacedert.Multiple(() =>
{
replacedert.That(SpyOutputWriter.AllOutput, Does.Contain("a > 0").And.Contains("a >= 0"));
replacedert.That(SpyOutputWriter.AllOutput, Does.Contain("killed").IgnoreCase);
replacedert.That(SpyOutputWriter.AllOutput, Does.Contain("skipped").And.Contains("skip reason").IgnoreCase);
});
}
19
Source : Verbose_mode.cs
with MIT License
from ComparetheMarket
with MIT License
from ComparetheMarket
[Test]
public void Then_detailed_mutation_testing_progress_is_not_output()
{
replacedert.Multiple(() =>
{
replacedert.That(SpyOutputWriter.AllOutput, Does.Not.Contain("a > 0").Or.Contains("a >= 0"));
replacedert.That(SpyOutputWriter.AllOutput, Does.Not.Contain("killed").IgnoreCase);
replacedert.That(SpyOutputWriter.AllOutput, Does.Not.Contain("skipped").IgnoreCase);
});
}
19
Source : NameOfContainingMember_Tests.cs
with MIT License
from ComparetheMarket
with MIT License
from ComparetheMarket
[Test]
public void Operators_are_supported()
{
var syntaxTree = CSharpSyntaxTree.ParseText(
@"namespace DummyNamespace
{
public clreplaced DummyClreplaced
{
public double x, y;
public static DummyClreplaced operator *(DummyClreplaced a, DummyClreplaced b)
{
return new DummyClreplaced { x = a.x + b.x, y = a.y + b.y };
}
public static implicit operator string(DummyClreplaced d)
{
return d.x.ToString();
}
}
}");
var compilation = CSharpCompilation.Create("Dummyreplacedembly", new [] { syntaxTree });
var semanticModel = compilation.GetSemanticModel(syntaxTree);
var returnStatementNodes = syntaxTree.GetRoot().DescendantNodes().OfType<ReturnStatementSyntax>().ToArray();
replacedert.Multiple(() =>
{
replacedert.That(returnStatementNodes[0].NameOfContainingMember(semanticModel),
Is.EqualTo("DummyNamespace.DummyClreplaced::operator *(DummyNamespace.DummyClreplaced,DummyNamespace.DummyClreplaced)"));
replacedert.That(returnStatementNodes[1].NameOfContainingMember(semanticModel),
Is.EqualTo("DummyNamespace.DummyClreplaced::operator string(DummyNamespace.DummyClreplaced)"));
});
}
19
Source : NUnitRunResults_Tests.cs
with MIT License
from ComparetheMarket
with MIT License
from ComparetheMarket
[Test]
public void When_results_xml_indicates_that_some_tests_failed_Then_error_field_contains_error_info()
{
var xmlNode = StringToXmlNode(
@"<?xml version=""1.0"" encoding=""utf-8"" standalone=""no""?>
<test-run id=""2"" result=""Failed"" total=""2"">
<test-suite runstate=""Runnable"">
<test-suite runstate=""Runnable"">
<test-case fullname=""HreplacedurvivingMutants.Tests.PartialNumberComparisonTests.IsPositive"">
<failure>
<message>error message 1</message>
<stack-trace>
<![CDATA[ at HreplacedurvivingMutants.Tests.PartialNumberComparisonTests.IsPositive() in C:\dev\fettle\src\Examples\HreplacedurvivingMutants\Tests\PartialNumberComparisonTests.cs:line 14 ]]>
</stack-trace>
</failure>
</test-case>
</test-suite>
<test-suite runstate=""Runnable"">
<test-case fullname=""HreplacedurvivingMutants.Tests.PartialNumberComparisonTests.IsNegative"">
<failure>
<message>error message 2</message>
<stack-trace>
<![CDATA[ at HreplacedurvivingMutants.Tests.PartialNumberComparisonTests.IsNegative() in C:\dev\fettle\src\Examples\HreplacedurvivingMutants\Tests\PartialNumberComparisonTests.cs:line 15 ]]>
</stack-trace>
</failure>
</test-case>
</test-suite>
</test-suite>
</test-run>
");
var result = NUnitRunResults.Parse(xmlNode);
replacedert.Multiple(() =>
{
replacedert.That(result.Error, Does.Contain("HreplacedurvivingMutants.Tests.PartialNumberComparisonTests.IsPositive"));
replacedert.That(result.Error, Does.Contain("PartialNumberComparisonTests.cs:line 14"));
replacedert.That(result.Error, Does.Contain("error message 1"));
replacedert.That(result.Error, Does.Contain("HreplacedurvivingMutants.Tests.PartialNumberComparisonTests.IsNegative"));
replacedert.That(result.Error, Does.Contain("PartialNumberComparisonTests.cs:line 15"));
replacedert.That(result.Error, Does.Contain("error message 2"));
});
}
19
Source : SurvivingMutant_Create_Tests.cs
with MIT License
from ComparetheMarket
with MIT License
from ComparetheMarket
[Test]
public async Task File_path_and_line_are_extracted_from_doreplacedent()
{
var survivingMutant = await CreateSurvivingMutantFromExpression(
originalExpression: "a > 0",
mutatedExpression: "a < 0");
replacedert.Multiple(() =>
{
replacedert.That(survivingMutant.SourceFilePath, Is.EqualTo(@"c:\someproject\somefile.cs"));
replacedert.That(survivingMutant.SourceLine, Is.EqualTo(7));
});
}
19
Source : SurvivingMutant_Create_Tests.cs
with MIT License
from ComparetheMarket
with MIT License
from ComparetheMarket
[Test]
public async Task Source_text_of_original_and_mutated_lines_are_extracted()
{
const string originalSource = "a > 0";
const string mutatedSource = "a < 0";
var survivingMutant = await CreateSurvivingMutantFromExpression(originalSource, mutatedSource);
replacedert.Multiple(() =>
{
replacedert.That(survivingMutant.OriginalLine.TrimStart(), Does.Contain(originalSource));
replacedert.That(survivingMutant.MutatedLine.TrimStart(), Does.Contain(mutatedSource));
});
}
19
Source : SurvivingMutant_Create_Tests.cs
with MIT License
from ComparetheMarket
with MIT License
from ComparetheMarket
[Test]
public async Task Source_text_of_original_and_mutated_lines_are_extracted_when_they_span_multiple_lines()
{
const string originalSource =
@"a > 0 &&
a != -1";
const string mutatedSource =
@"a < 0 &&
a != -1";
var survivingMutant = await CreateSurvivingMutantFromExpression(originalSource, mutatedSource);
replacedert.Multiple(() =>
{
replacedert.That(survivingMutant.OriginalLine.TrimStart(), Does.Contain(originalSource));
replacedert.That(survivingMutant.MutatedLine.TrimStart(), Does.Contain(mutatedSource));
});
}
19
Source : SurvivingMutant_Create_Tests.cs
with MIT License
from ComparetheMarket
with MIT License
from ComparetheMarket
[Test]
public async Task The_source_text_of_if_statements_does_not_include_the_if_statement_body()
{
const string originalExpression =
@"a > 0 &&
a != -1";
const string mutatedExpression =
@"a < 0 &&
a != -1";
var survivingMutant = await CreateSurvivingMutantFromIfStatement(originalExpression, mutatedExpression);
replacedert.Multiple(() =>
{
replacedert.That(survivingMutant.OriginalLine.TrimStart(), Is.EqualTo(
@"if (a > 0 &&
a != -1)"));
replacedert.That(survivingMutant.MutatedLine.TrimStart(), Is.EqualTo(
@"if (a < 0 &&
a != -1)"));
});
}
19
Source : Events.cs
with MIT License
from ComparetheMarket
with MIT License
from ComparetheMarket
[Test]
public void Then_event_listener_is_called_when_events_occur()
{
replacedert.Multiple(() =>
{
replacedert.That(SpyEventListener.HaveAnyFilesBegun);
replacedert.That(SpyEventListener.HaveAnyMembersBegun);
replacedert.That(SpyEventListener.HaveAnySyntaxNodesBegun);
replacedert.That(SpyEventListener.HaveAnyFilesEnded);
replacedert.That(SpyEventListener.HaveAnyMutantsSurvived);
replacedert.That(SpyEventListener.HaveAnyMutantsBeenKilled);
});
}
See More Examples