public CharacterBuildServiceTests(ITestOutputHelper output)
        {
            // Configure and load our user secrets
            var builder = new ConfigurationBuilder()
                          .AddUserSecrets <CharacterBuildServiceTests>();

            Configuration = builder.Build();

            // Create a temporary database to test against
            dbOptions = new DbContextOptionsBuilder <ApplicationDbContext>()
                        .UseCosmos(
                accountEndpoint: Configuration["Cosmos:Uri"],
                accountKey: Configuration["Cosmos:Key"],
                databaseName: $"Test-{Guid.NewGuid()}"
                )
                        .Options;

            using (var context = new ApplicationDbContext(dbOptions))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
            }

            // Set up AutoMapper like our Startup does
            var mappingConfig = new MapperConfiguration(mc => mc.AddProfile(new MappingProfile()));

            mapper = mappingConfig.CreateMapper();

            // Set up our valid users.  User 1 is admin.
            User1 = CreateTestUser(validUserId1, ValidUserName1, ValidUserHandle1, true);
            User2 = CreateTestUser(validUserId2, ValidUserName2, ValidUserHandle2, false);

            // This build driver creates build abstractions that accept any choice and
            // summarise by concatenating the choices.
            buildDriver = new TestBuildDriver(output);

            // This logger should log to the test output:
            logger = output.BuildLoggerFor <CharacterBuildService>();
        }
Beispiel #2
0
 public CharacterBuildService(IBuildDriver buildDriver, ApplicationDbContext context, ILogger <CharacterBuildService> logger, IMapper mapper, IToastService toastService, IUserManager userManager)
 => (this.buildDriver, this.context, this.logger, this.mapper, this.toastService, this.userManager) = (buildDriver, context, logger, mapper, toastService, userManager);