@@ -128,16 +128,17 @@ public void Test_NullableBool_Test_TestObject()
128
128
Assert . AreEqual ( null , obj . NullableBool , "Expected obj value to be null." ) ;
129
129
}
130
130
131
+ #pragma warning disable SA1124 // Do not use regions
132
+ #region System-based Unit Tests, See Issue #3198
133
+ #pragma warning restore SA1124 // Do not use regions
131
134
[ TestCategory ( "NullableBoolMarkupExtension" ) ]
135
+
132
136
[ UITestMethod ]
133
- public void Test_NullableBool_DependencyProperty_SystemTrueValueFails ( )
137
+ public void Test_NullableBool_DependencyProperty_SystemTrue ( )
134
138
{
135
139
// This is the failure case in the OS currently which causes us to need
136
140
// this markup extension.
137
- var exception = Assert . ThrowsException < XamlParseException > (
138
- ( ) =>
139
- {
140
- var treeroot = XamlReader . Load ( @"<Page
141
+ var treeroot = XamlReader . Load ( @"<Page
141
142
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
142
143
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
143
144
xmlns:ex=""using:Microsoft.Toolkit.Uwp.UI.Extensions""
@@ -146,12 +147,60 @@ public void Test_NullableBool_DependencyProperty_SystemTrueValueFails()
146
147
<helpers:ObjectWithNullableBoolProperty x:Key=""OurObject"" NullableBool=""True""/>
147
148
</Page.Resources>
148
149
</Page>" ) as FrameworkElement ;
149
- } , "Expected assignment failure during parsing, OS now supports, update documentation." ) ;
150
150
151
- Assert . IsNotNull ( exception ) ;
151
+ var obj = treeroot . Resources [ "OurObject" ] as ObjectWithNullableBoolProperty ;
152
+
153
+ Assert . IsNotNull ( obj , "Could not find object in resources." ) ;
154
+
155
+ Assert . AreEqual ( true , obj . NullableBool , "Expected obj value to be true." ) ;
156
+ }
157
+
158
+ [ TestCategory ( "NullableBoolMarkupExtension" ) ]
159
+ [ UITestMethod ]
160
+ public void Test_NullableBool_DependencyProperty_SystemFalse ( )
161
+ {
162
+ // This is the failure case in the OS currently which causes us to need
163
+ // this markup extension.
164
+ var treeroot = XamlReader . Load ( @"<Page
165
+ xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
166
+ xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
167
+ xmlns:ex=""using:Microsoft.Toolkit.Uwp.UI.Extensions""
168
+ xmlns:helpers=""using:UnitTests.Extensions.Helpers"">
169
+ <Page.Resources>
170
+ <helpers:ObjectWithNullableBoolProperty x:Key=""OurObject"" NullableBool=""False""/>
171
+ </Page.Resources>
172
+ </Page>" ) as FrameworkElement ;
173
+
174
+ var obj = treeroot . Resources [ "OurObject" ] as ObjectWithNullableBoolProperty ;
175
+
176
+ Assert . IsNotNull ( obj , "Could not find object in resources." ) ;
177
+
178
+ Assert . AreEqual ( false , obj . NullableBool , "Expected obj value to be true." ) ;
179
+ }
180
+
181
+ [ TestCategory ( "NullableBoolMarkupExtension" ) ]
182
+ [ UITestMethod ]
183
+ public void Test_NullableBool_DependencyProperty_SystemNull ( )
184
+ {
185
+ // This is the failure case in the OS currently which causes us to need
186
+ // this markup extension.
187
+ var treeroot = XamlReader . Load ( @"<Page
188
+ xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
189
+ xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
190
+ xmlns:ex=""using:Microsoft.Toolkit.Uwp.UI.Extensions""
191
+ xmlns:helpers=""using:UnitTests.Extensions.Helpers"">
192
+ <Page.Resources>
193
+ <helpers:ObjectWithNullableBoolProperty x:Key=""OurObject"" NullableBool=""{x:Null}""/>
194
+ </Page.Resources>
195
+ </Page>" ) as FrameworkElement ;
196
+
197
+ var obj = treeroot . Resources [ "OurObject" ] as ObjectWithNullableBoolProperty ;
198
+
199
+ Assert . IsNotNull ( obj , "Could not find object in resources." ) ;
152
200
153
- Assert . IsTrue ( exception . Message . Contains ( "Failed to create a 'Windows.Foundation.IReference`1<Boolean>' from the text 'True'." ) ) ;
201
+ Assert . IsNull ( obj . NullableBool , "Expected obj value to be null." ) ;
154
202
}
203
+ #endregion
155
204
156
205
[ TestCategory ( "NullableBoolMarkupExtension" ) ]
157
206
[ UITestMethod ]
0 commit comments