@@ -166,5 +166,93 @@ public void UseMauiCommunityToolkitMediaElement_ShouldSetDefaultAndroidViewType(
166166
167167 MediaElementOptions . DefaultAndroidViewType . Should ( ) . Be ( AndroidViewType . TextureView ) ;
168168 }
169+
170+ [ Fact ]
171+ public void UseMauiCommunityToolkitMediaElement_isAndroidForegroundServiceEnabledParameterFalse_IgnoreIsAndroidForegroundServiceEnabled_AndroidForegroundServiceShouldRemainDisabled ( )
172+ {
173+ MediaElementOptions . IsAndroidForegroundServiceEnabled . Should ( ) . Be ( false ) ;
174+
175+ var builder = MauiApp . CreateBuilder ( ) ;
176+ builder . UseMauiCommunityToolkitMediaElement ( isAndroidForegroundServiceEnabled : false , static options =>
177+ {
178+ options . SetDefaultAndroidViewType ( AndroidViewType . TextureView ) ;
179+ } ) ;
180+
181+ MediaElementOptions . IsAndroidForegroundServiceEnabled . Should ( ) . Be ( false ) ;
182+ }
183+
184+ [ Fact ]
185+ public void UseMauiCommunityToolkitMediaElement_isAndroidForegroundServiceEnabledParameterTrue_IgnoreIsAndroidForegroundServiceEnabled_ShouldEnableAndroidForegroundService ( )
186+ {
187+ MediaElementOptions . IsAndroidForegroundServiceEnabled . Should ( ) . Be ( false ) ;
188+
189+ var builder = MauiApp . CreateBuilder ( ) ;
190+ builder . UseMauiCommunityToolkitMediaElement ( isAndroidForegroundServiceEnabled : true , static options =>
191+ {
192+ options . SetDefaultAndroidViewType ( AndroidViewType . TextureView ) ;
193+ } ) ;
194+
195+ MediaElementOptions . IsAndroidForegroundServiceEnabled . Should ( ) . Be ( true ) ;
196+ }
197+
198+ [ Fact ]
199+ public void UseMauiCommunityToolkitMediaElement_isAndroidForegroundServiceEnabledParameterFalse_SetIsAndroidForegroundServiceEnabledFalse_AndroidForegroundServiceShouldRemainDisabled ( )
200+ {
201+ MediaElementOptions . IsAndroidForegroundServiceEnabled . Should ( ) . Be ( false ) ;
202+
203+ var builder = MauiApp . CreateBuilder ( ) ;
204+ builder . UseMauiCommunityToolkitMediaElement ( isAndroidForegroundServiceEnabled : false , static options =>
205+ {
206+ options . SetDefaultAndroidViewType ( AndroidViewType . TextureView ) ;
207+ options . SetIsAndroidForegroundServiceEnabled ( false ) ;
208+ } ) ;
209+
210+ MediaElementOptions . IsAndroidForegroundServiceEnabled . Should ( ) . Be ( false ) ;
211+ }
212+
213+ [ Fact ]
214+ public void UseMauiCommunityToolkitMediaElement_isAndroidForegroundServiceEnabledParameterTrue_SetIsAndroidForegroundServiceEnabledTrue_ShouldEnableAndroidForegroundService ( )
215+ {
216+ MediaElementOptions . IsAndroidForegroundServiceEnabled . Should ( ) . Be ( false ) ;
217+
218+ var builder = MauiApp . CreateBuilder ( ) ;
219+ builder . UseMauiCommunityToolkitMediaElement ( isAndroidForegroundServiceEnabled : true , static options =>
220+ {
221+ options . SetDefaultAndroidViewType ( AndroidViewType . TextureView ) ;
222+ options . SetIsAndroidForegroundServiceEnabled ( true ) ;
223+ } ) ;
224+
225+ MediaElementOptions . IsAndroidForegroundServiceEnabled . Should ( ) . Be ( true ) ;
226+ }
227+
228+ [ Fact ]
229+ public void UseMauiCommunityToolkitMediaElement_isAndroidForegroundServiceEnabledParameterFalse_SetIsAndroidForegroundServiceEnabledTrue_ShouldEnableAndroidForegroundService ( )
230+ {
231+ MediaElementOptions . IsAndroidForegroundServiceEnabled . Should ( ) . Be ( false ) ;
232+
233+ var builder = MauiApp . CreateBuilder ( ) ;
234+ builder . UseMauiCommunityToolkitMediaElement ( isAndroidForegroundServiceEnabled : false , static options =>
235+ {
236+ options . SetDefaultAndroidViewType ( AndroidViewType . TextureView ) ;
237+ options . SetIsAndroidForegroundServiceEnabled ( true ) ;
238+ } ) ;
239+
240+ MediaElementOptions . IsAndroidForegroundServiceEnabled . Should ( ) . Be ( true ) ;
241+ }
242+
243+ [ Fact ]
244+ public void UseMauiCommunityToolkitMediaElement_isAndroidForegroundServiceEnabledParameterTrue_SetIsAndroidForegroundServiceEnabledFalse_ShouldEnableAndroidForegroundService ( )
245+ {
246+ MediaElementOptions . IsAndroidForegroundServiceEnabled . Should ( ) . Be ( false ) ;
247+
248+ var builder = MauiApp . CreateBuilder ( ) ;
249+ builder . UseMauiCommunityToolkitMediaElement ( isAndroidForegroundServiceEnabled : true , static options =>
250+ {
251+ options . SetDefaultAndroidViewType ( AndroidViewType . TextureView ) ;
252+ options . SetIsAndroidForegroundServiceEnabled ( false ) ;
253+ } ) ;
254+
255+ MediaElementOptions . IsAndroidForegroundServiceEnabled . Should ( ) . Be ( true ) ;
256+ }
169257}
170258#pragma warning restore CA1416
0 commit comments