//using System.Collections.Generic; //using System.Linq; //using System.Threading; //using System.Threading.Tasks; //using AutoMapper; //using Microsoft.AspNetCore.Http; //using Microsoft.AspNetCore.Http.Features.Authentication; //using Microsoft.AspNetCore.Identity; //using Microsoft.AspNetCore.Identity.EntityFrameworkCore; //using Microsoft.EntityFrameworkCore; //using Microsoft.EntityFrameworkCore.Infrastructure; //using Microsoft.Extensions.DependencyInjection; //using Microsoft.Extensions.Options; //using Moq; //using NUnit.Framework; //using Ombi.Api.Emby; //using Ombi.Api.Plex; //using Ombi.Config; //using Ombi.Controllers; //using Ombi.Core.Authentication; //using Ombi.Core.Settings; //using Ombi.Core.Settings.Models.External; //using Ombi.Models; //using Ombi.Notifications; //using Ombi.Schedule.Jobs.Ombi; //using Ombi.Settings.Settings.Models; //using Ombi.Settings.Settings.Models.Notifications; //using Ombi.Store.Context; //using Ombi.Store.Entities; //namespace Ombi.Tests //{ // [TestFixture] // [Ignore("Need to sort out the DB, looks like it's using the real one...")] // public class IdentityControllerTests // { // [SetUp] // public void Setup() // { // _plexApi = new Mock(); // _embyApi = new Mock(); // _mapper = new Mock(); // _emailProvider = new Mock(); // _emailSettings = new Mock>(); // _customizationSettings = new Mock>(); // _welcomeEmail = new Mock(); // _embySettings = new Mock>(); // _plexSettings = new Mock>(); // var services = new ServiceCollection(); // services.AddEntityFrameworkInMemoryDatabase() // .AddDbContext(); // services.AddIdentity() // .AddEntityFrameworkStores().AddUserManager(); // services.AddTransient(x => _plexApi.Object); // services.AddTransient(x => _embyApi.Object); // services.AddTransient(x => _customizationSettings.Object); // services.AddTransient(x => _welcomeEmail.Object); // services.AddTransient(x => _emailSettings.Object); // services.AddTransient(x => _emailProvider.Object); // services.AddTransient(x => _mapper.Object); // services.AddTransient(x => _embySettings.Object); // services.AddTransient(x => _plexSettings.Object); // services.Configure(options => // { // options.Password.RequireDigit = false; // options.Password.RequiredLength = 1; // options.Password.RequireLowercase = false; // options.Password.RequireNonAlphanumeric = false; // options.Password.RequireUppercase = false; // options.User.AllowedUserNameCharacters = string.Empty; // }); // // Taken from https://github.com/aspnet/MusicStore/blob/dev/test/MusicStore.Test/ManageControllerTest.cs (and modified) // var context = new DefaultHttpContext(); // context.Features.Set(new HttpAuthenticationFeature()); // services.AddSingleton(h => new HttpContextAccessor { HttpContext = context }); // _serviceProvider = services.BuildServiceProvider(); // _userManager = _serviceProvider.GetRequiredService(); // Controller = new IdentityController(_userManager, _mapper.Object, // _serviceProvider.GetService>(), _emailProvider.Object, // _emailSettings.Object, _customizationSettings.Object, _welcomeEmail.Object, null, null, null, null, // null, null, null, null, null); // } // private OmbiUserManager _userManager; // private Mock _emailProvider; // private Mock> _emailSettings; // private Mock> _customizationSettings; // private Mock> _embySettings; // private Mock> _plexSettings; // private Mock _welcomeEmail; // private Mock _mapper; // private Mock _plexApi; // private Mock _embyApi; // private ServiceProvider _serviceProvider; // private IdentityController Controller { get; set; } // [Test] // public async Task CreateWizardUser_Should_CreateUser_WhenThereAreNoOtherUsers() // { // var model = new CreateUserWizardModel() // { // Password = "a", // Username = "b" // }; // var result = await Controller.CreateWizardUser(model); // Assert.That(result, Is.True); // } // [Test] // public async Task CreateWizardUser_ShouldNot_CreateUser_WhenThereAreOtherUsers() // { // var um = _serviceProvider.GetService(); // var r = await um.CreateAsync(new OmbiUser { UserName = "aaaa",UserType = UserType.LocalUser}, "bbb"); // var model = new CreateUserWizardModel // { // Password = "a", // Username = "b" // }; // var result = await Controller.CreateWizardUser(model); // Assert.That(result, Is.False); // } // } //}