コード例 #1
0
        public void ShouldGetConstructorWithOptionalParameter()
        {
            // Arrange
            var args = new object[]
            {
                EmployeeContextTestDbConnection.CreateDbContextOptions <TestAuditDbContext>(),
                new DropCreateDatabaseAlways <TestAuditDbContext>(),
            };

            // Act
            var contextCtor = typeof(TestAuditDbContext).GetMatchingConstructor(args);

            // Assert
            var contextCtorParameters = contextCtor.ConstructorInfo.GetParameters();

            contextCtorParameters.Should().HaveCount(2);
            contextCtorParameters.ElementAt(0).ParameterType.Should().Be(typeof(DbContextOptions));
            contextCtorParameters.ElementAt(1).ParameterType.Should().Be(typeof(IDatabaseInitializer <TestAuditDbContext>));

            var testContext = contextCtor.Invoke();

            testContext.Should().BeOfType <TestAuditDbContext>();
        }
コード例 #2
0
 public PersonRepositoryTests(ITestOutputHelper testOutputHelper)
     : base(dbContextOptions: EmployeeContextTestDbConnection.CreateDbContextOptions <EmployeeContext>(),
            databaseInitializer: new EmployeeContextDatabaseInitializer(new List <IDataSeed> { new CountryDataSeed() }),
            log: testOutputHelper.WriteLine)
 {
 }