Created
December 29, 2023 16:47
-
-
Save dperish/dede439f0ff5033688e16d91fa5b6ebc to your computer and use it in GitHub Desktop.
AutoFixture customizations for .net Maui
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.ObjectModel; | |
using System.Collections.Specialized; | |
using AutoFixture.AutoMoq; | |
using AutoFixture; | |
using AutoFixture.AutoNSubstitute; | |
using AutoFixture.Kernel; | |
using AutoFixture.Xunit2; | |
using Objectivity.AutoFixture.XUnit2.Core.Customizations; | |
namespace BS.Pool.App.Tests.Customizations; | |
public class AutoDomainDataAttribute : AutoDataAttribute | |
{ | |
public AutoDomainDataAttribute() | |
: base(() => new Fixture() | |
.Customize(new AutoNSubstituteCustomization()) | |
.Customize(new AutoMoqCustomization()) | |
.Customize(new IgnoreVirtualMembersCustomization()) | |
.Customize(new MauiProvidersCustomization()) | |
) | |
{ | |
} | |
} | |
public class MauiProvidersCustomization : ICustomization | |
{ | |
public void Customize(IFixture fixture) | |
{ | |
fixture.Customizations.Add( | |
new TypeRelay( | |
typeof(Shell), | |
typeof(FakeShell))); | |
} | |
} | |
public class SubstituteRelay<T> : CompositeSpecimenBuilder | |
{ | |
public SubstituteRelay() | |
: base(new SubstituteRelay(new ExactTypeSpecification(typeof(T)))) | |
{ | |
} | |
} | |
public class FakeShell : Page, | |
IFlyoutView, | |
IView, | |
IElement, | |
ITransform, | |
IShellController, | |
IPageController, | |
IVisualElementController, | |
IElementController, | |
IPageContainer<Page> | |
{ | |
public IView Flyout { get; } | |
public IView Detail { get; } | |
public bool IsPresented { get; set; } | |
public FlyoutBehavior FlyoutBehavior { get; } | |
public double FlyoutWidth { get; } | |
public bool IsGestureEnabled { get; } | |
public void AddAppearanceObserver(IAppearanceObserver observer, Element pivot) | |
{ | |
throw new NotImplementedException(); | |
} | |
public void AddFlyoutBehaviorObserver(IFlyoutBehaviorObserver observer) | |
{ | |
throw new NotImplementedException(); | |
} | |
public void AppearanceChanged(Element source, bool appearanceSet) | |
{ | |
throw new NotImplementedException(); | |
} | |
public List<List<Element>> GenerateFlyoutGrouping() | |
{ | |
throw new NotImplementedException(); | |
} | |
public ShellNavigationState GetNavigationState(ShellItem shellItem, ShellSection shellSection, ShellContent shellContent, | |
bool includeStack = true) | |
{ | |
throw new NotImplementedException(); | |
} | |
public void OnFlyoutItemSelected(Element element) | |
{ | |
throw new NotImplementedException(); | |
} | |
public Task OnFlyoutItemSelectedAsync(Element element) | |
{ | |
throw new NotImplementedException(); | |
} | |
public bool ProposeNavigation(ShellNavigationSource source, ShellItem item, ShellSection shellSection, | |
ShellContent shellContent, IReadOnlyList<Page> stack, bool canCancel) | |
{ | |
throw new NotImplementedException(); | |
} | |
public bool RemoveAppearanceObserver(IAppearanceObserver observer) | |
{ | |
throw new NotImplementedException(); | |
} | |
public bool RemoveFlyoutBehaviorObserver(IFlyoutBehaviorObserver observer) | |
{ | |
throw new NotImplementedException(); | |
} | |
public void UpdateCurrentState(ShellNavigationSource source) | |
{ | |
throw new NotImplementedException(); | |
} | |
public ReadOnlyCollection<ShellItem> GetItems() | |
{ | |
throw new NotImplementedException(); | |
} | |
public DataTemplate GetFlyoutItemDataTemplate(BindableObject bo) | |
{ | |
throw new NotImplementedException(); | |
} | |
public View FlyoutHeader { get; } | |
public View FlyoutFooter { get; } | |
public View FlyoutContent { get; } | |
public ImageSource FlyoutIcon { get; } | |
public event EventHandler? StructureChanged; | |
public event EventHandler? FlyoutItemsChanged; | |
public event NotifyCollectionChangedEventHandler? ItemsCollectionChanged; | |
public Page CurrentPage { get; } = new(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment