@@ -122,5 +122,56 @@ public void MarginsCannotHaveNegativeValues()
122122 Assert . That ( ( ) => new PrintOptions . Margins { Left = - 1 } , Throws . TypeOf < ArgumentOutOfRangeException > ( ) ) ;
123123 Assert . That ( ( ) => new PrintOptions . Margins { Right = - 1 } , Throws . TypeOf < ArgumentOutOfRangeException > ( ) ) ;
124124 }
125+
126+ [ Test ]
127+ public void DefaultPageSizeIsA4 ( )
128+ {
129+ var options = new PrintOptions ( ) ;
130+
131+ Assert . That ( options . PageDimensions . Width , Is . EqualTo ( PrintOptions . A4 . Width ) ) ;
132+ Assert . That ( options . PageDimensions . Height , Is . EqualTo ( PrintOptions . A4 . Height ) ) ;
133+ }
134+
135+ [ Test ]
136+ public void CanSetPredefinedPageSizes ( )
137+ {
138+ var options = new PrintOptions ( ) ;
139+
140+ options . SetPageSize ( PrintOptions . A4 ) ;
141+ Assert . That ( options . PageDimensions . Width , Is . EqualTo ( PrintOptions . A4 . Width ) ) ;
142+ Assert . That ( options . PageDimensions . Height , Is . EqualTo ( PrintOptions . A4 . Height ) ) ;
143+
144+ options . SetPageSize ( PrintOptions . Legal ) ;
145+ Assert . That ( options . PageDimensions . Width , Is . EqualTo ( PrintOptions . Legal . Width ) ) ;
146+ Assert . That ( options . PageDimensions . Height , Is . EqualTo ( PrintOptions . Legal . Height ) ) ;
147+
148+ options . SetPageSize ( PrintOptions . Letter ) ;
149+ Assert . That ( options . PageDimensions . Width , Is . EqualTo ( PrintOptions . Letter . Width ) ) ;
150+ Assert . That ( options . PageDimensions . Height , Is . EqualTo ( PrintOptions . Letter . Height ) ) ;
151+
152+ options . SetPageSize ( PrintOptions . Tabloid ) ;
153+ Assert . That ( options . PageDimensions . Width , Is . EqualTo ( PrintOptions . Tabloid . Width ) ) ;
154+ Assert . That ( options . PageDimensions . Height , Is . EqualTo ( PrintOptions . Tabloid . Height ) ) ;
155+ }
156+
157+ [ Test ]
158+ public void CanSetCustomPageSize ( )
159+ {
160+ var options = new PrintOptions ( ) ;
161+ var customPageSize = new PrintOptions . PageSize { Width = 25.0 , Height = 30.0 } ;
162+
163+ options . SetPageSize ( customPageSize ) ;
164+
165+ Assert . That ( options . PageDimensions . Width , Is . EqualTo ( 25.0 ) ) ;
166+ Assert . That ( options . PageDimensions . Height , Is . EqualTo ( 30.0 ) ) ;
167+ }
168+
169+ [ Test ]
170+ public void SettingPageSizeToNullThrowsException ( )
171+ {
172+ var options = new PrintOptions ( ) ;
173+ Assert . That ( ( ) => options . SetPageSize ( null ) , Throws . InstanceOf < ArgumentNullException > ( ) ) ;
174+ }
175+
125176 }
126177}
0 commit comments