1+ using CommunityToolkit . Maui . Core ;
2+ using Xunit ;
3+
4+ namespace CommunityToolkit . Maui . UnitTests . Extensions ;
5+
6+ public class AppBuilderExtensionsTests : BaseTest
7+ {
8+ [ Fact ]
9+ public void ConfirmOptionsDefaultValue ( )
10+ {
11+ // Assert
12+ Assert . True ( Core . Options . ShouldUseStatusBarBehaviorOnAndroidModalPage ) ;
13+ Assert . False ( Options . ShouldEnableSnackbarOnWindows ) ;
14+ Assert . False ( Options . ShouldSuppressExceptionsInAnimations ) ;
15+ Assert . False ( Options . ShouldSuppressExceptionsInBehaviors ) ;
16+ Assert . False ( Options . ShouldSuppressExceptionsInConverters ) ;
17+ }
18+
19+ [ Fact ]
20+ public void UseMauiCommunityToolkit_ShouldRegisterServices ( )
21+ {
22+ // Arrange
23+ var builder = MauiApp . CreateBuilder ( ) ;
24+
25+ // Act
26+ #pragma warning disable CA1416
27+ builder . UseMauiCommunityToolkit ( ) ;
28+ #pragma warning restore CA1416
29+
30+ // Assert
31+ var serviceProvider = builder . Services . BuildServiceProvider ( ) ;
32+ Assert . NotNull ( serviceProvider . GetService < IPopupService > ( ) ) ;
33+ }
34+
35+ [ Fact ]
36+ public void UseMauiCommunityToolkit_ShouldAssignValues ( )
37+ {
38+ // Arrange
39+ var builder = MauiApp . CreateBuilder ( ) ;
40+
41+ // Act
42+ #pragma warning disable CA1416
43+ builder . UseMauiCommunityToolkit ( options =>
44+ {
45+ options . SetShouldEnableSnackbarOnWindows ( ! Options . ShouldEnableSnackbarOnWindows ) ;
46+ options . SetShouldUseStatusBarBehaviorOnAndroidModalPage ( ! Core . Options . ShouldUseStatusBarBehaviorOnAndroidModalPage ) ;
47+ options . SetShouldSuppressExceptionsInAnimations ( ! Options . ShouldSuppressExceptionsInAnimations ) ;
48+ options . SetShouldSuppressExceptionsInBehaviors ( ! Options . ShouldSuppressExceptionsInBehaviors ) ;
49+ options . SetShouldSuppressExceptionsInConverters ( ! Options . ShouldSuppressExceptionsInConverters ) ;
50+ } ) ;
51+ #pragma warning restore CA1416
52+
53+ // Assert
54+ Assert . False ( Core . Options . ShouldUseStatusBarBehaviorOnAndroidModalPage ) ;
55+ Assert . True ( Options . ShouldEnableSnackbarOnWindows ) ;
56+ Assert . True ( Options . ShouldSuppressExceptionsInAnimations ) ;
57+ Assert . True ( Options . ShouldSuppressExceptionsInBehaviors ) ;
58+ Assert . True ( Options . ShouldSuppressExceptionsInConverters ) ;
59+ }
60+ }
0 commit comments