/// <summary> /// Use the added services /// </summary> /// <param name="app">The application builder</param> /// <param name="environment">The environment</param> /// <param name="dbContext">The database context</param> /// <param name="seedService">The entity seed service</param> public static void UseUsersApiServices(this IApplicationBuilder app, IWebHostEnvironment environment, ForexMinerHeimdallrDbContext dbContext, IEntitySeedService seedService) { // CORS app.UseCorsPolicy(); // ProblemDetails app.UseProblemDetails(environment.IsDevelopment()); // Database migration dbContext.MigrateDatabase(environment.IsDevelopment()); // Seeding seedService.Seed(); }
public void Seed_Exists() { // Arrange var adminUserMock = new User() { Id = Guid.NewGuid(), Email = "*****@*****.**", FirstName = "Unit", LastName = "Test", Role = Role.Admin, HasConnections = false }; _configurationMock.SetupGet(c => c[It.Is <string>(cv => cv == "SuperAdmin-Email")]).Returns(adminUserMock.Email); _userServiceMock.Setup(us => us.GetUserByEmail(adminUserMock.Email)).Returns(adminUserMock); // Act _userSeedService.Seed(); // Assert _configurationMock.VerifyGet(c => c["SuperAdmin-Email"], Times.Once()); _configurationMock.VerifyGet(c => c["SuperAdmin-Password"], Times.Never()); _userServiceMock.Verify(us => us.Register(It.IsAny <Registration>(), It.IsAny <Role>()), Times.Never()); }