// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; namespace Microsoft.AspNetCore.Identity.FunctionalTests { public class DefaultUIContext : HtmlPageContext { public DefaultUIContext() { } public DefaultUIContext(DefaultUIContext currentContext) : base(currentContext) { } public DefaultUIContext WithAuthenticatedUser() => new DefaultUIContext(this) { UserAuthenticated = true }; public DefaultUIContext WithAnonymousUser() => new DefaultUIContext(this) { UserAuthenticated = false }; public DefaultUIContext WithSocialLoginEnabled() => new DefaultUIContext(this) { ContosoLoginEnabled = true }; public DefaultUIContext WithExistingUser() => new DefaultUIContext(this) { ExistingUser = true }; public DefaultUIContext WithConfirmedEmail() => new DefaultUIContext(this) { EmailConfirmed = true }; internal DefaultUIContext WithSocialLoginProvider() => new DefaultUIContext(this) { SocialLoginProvider = "contoso" }; internal DefaultUIContext WithPasswordLogin() => new DefaultUIContext(this) { PasswordLoginEnabled = true }; internal DefaultUIContext WithCookieConsent() => new DefaultUIContext(this) { CookiePolicyAccepted = true }; public string AuthenticatorKey { get => GetValue(nameof(AuthenticatorKey)); set => SetValue(nameof(AuthenticatorKey), value); } public string SocialLoginProvider { get => GetValue(nameof(SocialLoginProvider)); set => SetValue(nameof(SocialLoginProvider), value); } public string[] RecoveryCodes { get => GetValue(nameof(RecoveryCodes)); set => SetValue(nameof(RecoveryCodes), value); } public bool TwoFactorEnabled { get => GetValue(nameof(TwoFactorEnabled)); set => SetValue(nameof(TwoFactorEnabled), value); } public bool ContosoLoginEnabled { get => GetValue(nameof(ContosoLoginEnabled)); set => SetValue(nameof(ContosoLoginEnabled), value); } public bool UserAuthenticated { get => GetValue(nameof(UserAuthenticated)); set => SetValue(nameof(UserAuthenticated), value); } public bool ExistingUser { get => GetValue(nameof(ExistingUser)); set => SetValue(nameof(ExistingUser), value); } public bool EmailConfirmed { get => GetValue(nameof(ExistingUser)); set => SetValue(nameof(ExistingUser), value); } public bool PasswordLoginEnabled { get => GetValue(nameof(PasswordLoginEnabled)); set => SetValue(nameof(PasswordLoginEnabled), value); } public bool CookiePolicyAccepted { get => GetValue(nameof(CookiePolicyAccepted)); set => SetValue(nameof(CookiePolicyAccepted), value); } } }