1- // Copyright (c) Six Labors and contributors.
2- // Licensed under the Apache License, Version 2.0.
3-
4- using System ;
5- using System . Collections . Generic ;
6- using System . IO ;
7- using System . Linq ;
8- using SixLabors . ImageSharp . Formats ;
9- using SixLabors . ImageSharp . IO ;
10- using SixLabors . ImageSharp . PixelFormats ;
11- using Moq ;
12- using Xunit ;
13-
14- namespace SixLabors . ImageSharp . Tests
15- {
16- /// <summary>
17- /// Tests the configuration class.
18- /// </summary>
19- public class ConfigurationTests
20- {
21- public Configuration ConfigurationEmpty { get ; private set ; }
22- public Configuration DefaultConfiguration { get ; private set ; }
23-
24- public ConfigurationTests ( )
25- {
26- // the shallow copy of configuration should behave exactly like the default configuration,
27- // so by using the copy, we test both the default and the copy.
28- this . DefaultConfiguration = Configuration . CreateDefaultInstance ( ) . ShallowCopy ( ) ;
29- this . ConfigurationEmpty = new Configuration ( ) ;
30- }
31-
32- [ Fact ]
33- public void DefaultsToLocalFileSystem ( )
34- {
35- Assert . IsType < LocalFileSystem > ( this . DefaultConfiguration . FileSystem ) ;
36- Assert . IsType < LocalFileSystem > ( this . ConfigurationEmpty . FileSystem ) ;
37- }
38-
39- /// <summary>
40- /// Test that the default configuration is not null.
41- /// </summary>
42- [ Fact ]
43- public void TestDefultConfigurationIsNotNull ( )
44- {
45- Assert . True ( Configuration . Default != null ) ;
46- }
47-
48- /// <summary>
49- /// Test that the default configuration parallel options is not null.
50- /// </summary>
51- [ Fact ]
52- public void TestDefultConfigurationParallelOptionsIsNotNull ( )
53- {
54- Assert . True ( Configuration . Default . ParallelOptions != null ) ;
55- }
56-
57- /// <summary>
58- /// Test that the default configuration read origin options is set to begin.
59- /// </summary>
60- [ Fact ]
61- public void TestDefultConfigurationReadOriginIsCurrent ( )
62- {
63- Assert . True ( Configuration . Default . ReadOrigin == ReadOrigin . Current ) ;
64- }
65-
66- /// <summary>
67- /// Test that the default configuration parallel options max degrees of parallelism matches the
68- /// environment processor count.
69- /// </summary>
70- [ Fact ]
71- public void TestDefultConfigurationMaxDegreeOfParallelism ( )
72- {
73- Assert . True ( Configuration . Default . ParallelOptions . MaxDegreeOfParallelism == Environment . ProcessorCount ) ;
74- }
75-
76- [ Fact ]
77- public void ConstructorCallConfigureOnFormatProvider ( )
78- {
79- var provider = new Mock < IConfigurationModule > ( ) ;
80- var config = new Configuration ( provider . Object ) ;
81-
82- provider . Verify ( x => x . Configure ( config ) ) ;
83- }
84-
85- [ Fact ]
86- public void AddFormatCallsConfig ( )
87- {
88- var provider = new Mock < IConfigurationModule > ( ) ;
89- var config = new Configuration ( ) ;
90- config . Configure ( provider . Object ) ;
91-
92- provider . Verify ( x => x . Configure ( config ) ) ;
93- }
94- }
1+ // Copyright (c) Six Labors and contributors.
2+ // Licensed under the Apache License, Version 2.0.
3+
4+ using System ;
5+ using System . Collections . Generic ;
6+ using System . IO ;
7+ using System . Linq ;
8+ using SixLabors . ImageSharp . Formats ;
9+ using SixLabors . ImageSharp . IO ;
10+ using SixLabors . ImageSharp . PixelFormats ;
11+ using Moq ;
12+ using Xunit ;
13+
14+ namespace SixLabors . ImageSharp . Tests
15+ {
16+ /// <summary>
17+ /// Tests the configuration class.
18+ /// </summary>
19+ public class ConfigurationTests
20+ {
21+ public Configuration ConfigurationEmpty { get ; private set ; }
22+ public Configuration DefaultConfiguration { get ; private set ; }
23+
24+ public ConfigurationTests ( )
25+ {
26+ // the shallow copy of configuration should behave exactly like the default configuration,
27+ // so by using the copy, we test both the default and the copy.
28+ this . DefaultConfiguration = Configuration . CreateDefaultInstance ( ) . ShallowCopy ( ) ;
29+ this . ConfigurationEmpty = new Configuration ( ) ;
30+ }
31+
32+ [ Fact ]
33+ public void DefaultsToLocalFileSystem ( )
34+ {
35+ Assert . IsType < LocalFileSystem > ( this . DefaultConfiguration . FileSystem ) ;
36+ Assert . IsType < LocalFileSystem > ( this . ConfigurationEmpty . FileSystem ) ;
37+ }
38+
39+ /// <summary>
40+ /// Test that the default configuration is not null.
41+ /// </summary>
42+ [ Fact ]
43+ public void TestDefaultConfigurationIsNotNull ( )
44+ {
45+ Assert . True ( Configuration . Default != null ) ;
46+ }
47+
48+ /// <summary>
49+ /// Test that the default configuration parallel options is not null.
50+ /// </summary>
51+ [ Fact ]
52+ public void TestDefaultConfigurationParallelOptionsIsNotNull ( )
53+ {
54+ Assert . True ( Configuration . Default . ParallelOptions != null ) ;
55+ }
56+
57+ /// <summary>
58+ /// Test that the default configuration read origin options is set to begin.
59+ /// </summary>
60+ [ Fact ]
61+ public void TestDefaultConfigurationReadOriginIsCurrent ( )
62+ {
63+ Assert . True ( Configuration . Default . ReadOrigin == ReadOrigin . Current ) ;
64+ }
65+
66+ /// <summary>
67+ /// Test that the default configuration parallel options max degrees of parallelism matches the
68+ /// environment processor count.
69+ /// </summary>
70+ [ Fact ]
71+ public void TestDefaultConfigurationMaxDegreeOfParallelism ( )
72+ {
73+ Assert . True ( Configuration . Default . ParallelOptions . MaxDegreeOfParallelism == Environment . ProcessorCount ) ;
74+ }
75+
76+ [ Fact ]
77+ public void ConstructorCallConfigureOnFormatProvider ( )
78+ {
79+ var provider = new Mock < IConfigurationModule > ( ) ;
80+ var config = new Configuration ( provider . Object ) ;
81+
82+ provider . Verify ( x => x . Configure ( config ) ) ;
83+ }
84+
85+ [ Fact ]
86+ public void AddFormatCallsConfig ( )
87+ {
88+ var provider = new Mock < IConfigurationModule > ( ) ;
89+ var config = new Configuration ( ) ;
90+ config . Configure ( provider . Object ) ;
91+
92+ provider . Verify ( x => x . Configure ( config ) ) ;
93+ }
94+ }
9595}
0 commit comments