File tree Expand file tree Collapse file tree 7 files changed +24
-14
lines changed
Factories/SettingsFactoryTests
MagickImageCollectionTests Expand file tree Collapse file tree 7 files changed +24
-14
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,9 @@ public interface ISettingsFactory<TQuantumType>
2222 /// <summary>
2323 /// Initializes a new instance that implements <see cref="IComplexSettings"/>.
2424 /// </summary>
25+ /// <param name="complexOperator">The complex operator to use.</param>
2526 /// <returns>A new <see cref="IComplexSettings"/> instance.</returns>
26- IComplexSettings CreateComplexSettings ( ) ;
27+ IComplexSettings CreateComplexSettings ( ComplexOperator complexOperator ) ;
2728
2829 /// <summary>
2930 /// Initializes a new instance that implements <see cref="IConnectedComponentsSettings"/>.
Original file line number Diff line number Diff line change @@ -9,9 +9,9 @@ namespace ImageMagick;
99public interface IComplexSettings
1010{
1111 /// <summary>
12- /// Gets or sets the complex operator.
12+ /// Gets the complex operator.
1313 /// </summary>
14- ComplexOperator ComplexOperator { get ; set ; }
14+ ComplexOperator ComplexOperator { get ; }
1515
1616 /// <summary>
1717 /// Gets or sets the signal to noise ratio.
Original file line number Diff line number Diff line change @@ -29,9 +29,10 @@ public ICompareSettings<QuantumType> CreateCompareSettings(ErrorMetric metric)
2929 /// <summary>
3030 /// Initializes a new instance that implements <see cref="IComplexSettings"/>.
3131 /// </summary>
32+ /// <param name="complexOperator">The complex operator to use.</param>
3233 /// <returns>A new <see cref="IComplexSettings"/> instance.</returns>
33- public IComplexSettings CreateComplexSettings ( )
34- => new ComplexSettings ( ) ;
34+ public IComplexSettings CreateComplexSettings ( ComplexOperator complexOperator )
35+ => new ComplexSettings ( complexOperator ) ;
3536
3637 /// <summary>
3738 /// Initializes a new instance that implements <see cref="IConnectedComponentsSettings"/>.
Original file line number Diff line number Diff line change @@ -442,12 +442,12 @@ public void Complex(IComplexSettings complexSettings)
442442 {
443443 Throw . IfNull ( nameof ( complexSettings ) , complexSettings ) ;
444444
445+ using var imageAttacher = new TemporaryImageAttacher ( _images ) ;
445446 using var temporaryDefines = new TemporaryDefines ( _images [ 0 ] ) ;
446447
447448 if ( complexSettings . SignalToNoiseRatio is not null )
448449 temporaryDefines . SetArtifact ( "complex:snr" , complexSettings . SignalToNoiseRatio . Value . ToString ( CultureInfo . InvariantCulture ) ) ;
449450
450- using var imageAttacher = new TemporaryImageAttacher ( _images ) ;
451451 var images = _nativeInstance . Complex ( _images [ 0 ] , complexSettings . ComplexOperator ) ;
452452 ReplaceImages ( images ) ;
453453 }
Original file line number Diff line number Diff line change @@ -9,9 +9,18 @@ namespace ImageMagick;
99public sealed class ComplexSettings : IComplexSettings
1010{
1111 /// <summary>
12- /// Gets or sets the complex operator .
12+ /// Initializes a new instance of the <see cref="ComplexSettings"/> class .
1313 /// </summary>
14- public ComplexOperator ComplexOperator { get ; set ; }
14+ /// <param name="complexOperator">The complex operator.</param>
15+ public ComplexSettings ( ComplexOperator complexOperator )
16+ {
17+ ComplexOperator = complexOperator ;
18+ }
19+
20+ /// <summary>
21+ /// Gets the complex operator.
22+ /// </summary>
23+ public ComplexOperator ComplexOperator { get ; }
1524
1625 /// <summary>
1726 /// Gets or sets the signal to noise ratio.
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public void ShouldCreateInstance()
1616 {
1717 var factory = new SettingsFactory ( ) ;
1818
19- var settings = factory . CreateComplexSettings ( ) ;
19+ var settings = factory . CreateComplexSettings ( ComplexOperator . MagnitudePhase ) ;
2020
2121 Assert . NotNull ( settings ) ;
2222 Assert . IsType < ComplexSettings > ( settings ) ;
Original file line number Diff line number Diff line change @@ -15,8 +15,9 @@ public class TheComplexMethod
1515 public void ShouldThrowExceptionWhenCollectionIsEmpty ( )
1616 {
1717 using var images = new MagickImageCollection ( ) ;
18+ var settings = new ComplexSettings ( ComplexOperator . RealImaginary ) ;
1819
19- Assert . Throws < InvalidOperationException > ( ( ) => images . Complex ( new ComplexSettings ( ) ) ) ;
20+ Assert . Throws < InvalidOperationException > ( ( ) => images . Complex ( settings ) ) ;
2021 }
2122
2223 [ Fact ]
@@ -36,10 +37,8 @@ public void ShouldApplyTheOperatorToTheImages()
3637 using var images = new MagickImageCollection ( ) ;
3738 images . Read ( Files . RoseSparkleGIF ) ;
3839
39- images . Complex ( new ComplexSettings
40- {
41- ComplexOperator = ComplexOperator . Conjugate ,
42- } ) ;
40+ var settings = new ComplexSettings ( ComplexOperator . Conjugate ) ;
41+ images . Complex ( settings ) ;
4342
4443 Assert . Equal ( 2 , images . Count ) ;
4544
You can’t perform that action at this time.
0 commit comments