コード例 #1
0
ファイル: WebTest.cs プロジェクト: woxihuanjia/Coderr.Server
        static WebTest()
        {
            var mapper = new AssemblyScanningMappingProvider();

            mapper.Scan(typeof(AccountRepository).Assembly);
            EntityMappingProvider.Provider = mapper;

            _databaseManager.CreateEmptyDatabase();
            _databaseManager.InitSchema();

            AppDomain.CurrentDomain.DomainUnload += (o, e) =>
            {
                _iisExpress?.Stop();
                _databaseManager.Dispose();
            };

            // Disables database migration in codeRR.Server.Web project, should be up-to-date already
            // SchemaUpdateModule does not handle coderr_ConnectionString environment variable
            // This should only be run on build server due to changes in web.config
            if (Environment.GetEnvironmentVariable("TF_BUILD") != null)
            {
                DisableDatabaseMigrations();
            }

            var configPath =
                Path.Combine(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\")),
                             "applicationhost.config");

            Console.WriteLine($"Path to IIS Express configuration file '{configPath}'");

            _iisExpress = new IisExpressHelper
            {
                ConfigPath = configPath,

                // Pass on connectionstring to codeRR.Server.Web during testing, overriding connectionstring in web.config
                EnvironmentVariables = new Dictionary <string, string> {
                    { "coderr_ConnectionString", _databaseManager.ConnectionString }
                }
            };
            _iisExpress.Start("codeRR.Server.Web");

            // Warmup request only on build server
            if (Environment.GetEnvironmentVariable("TF_BUILD") != null)
            {
                var webClient = new WebClient();
                webClient.DownloadString(_iisExpress.BaseUrl);
            }

            TestUser = new TestUser {
                Username = "******", Password = "******", Email = "*****@*****.**"
            };

            TestData = new TestDataManager(_databaseManager.OpenConnection)
            {
                TestUser = TestUser
            };

            WebDriver = DriverFactory.Create(BrowserType.Chrome);
            AppDomain.CurrentDomain.DomainUnload += (o, e) => { DisposeWebDriver(); };
        }
コード例 #2
0
        private static void ConfigureDataMapping()
        {
            var provider = new AssemblyScanningMappingProvider();

            provider.Scan(typeof(UserMapper).Assembly);
            EntityMappingProvider.Provider = provider;
        }
コード例 #3
0
        static IntegrationTest()
        {
            var path2 = AppDomain.CurrentDomain.BaseDirectory;

            var logRepository = LogManager.GetRepository(Assembly.GetExecutingAssembly());

            XmlConfigurator.ConfigureAndWatch(logRepository, new FileInfo(Path.Combine(path2, "log4net.config")));
            var logger = LogManager.GetLogger(typeof(IntegrationTest));

            logger.Info("Loaded");



            AppDomain.CurrentDomain.DomainUnload += (o, e) =>
            {
                if (_databaseManager == null)
                {
                    return;
                }
                _databaseManager.Dispose();
                _databaseManager = null;
            };
            lock (SyncLock)
            {
                _databaseManager = new DatabaseManager();
                _databaseManager.CreateEmptyDatabase();
                _databaseManager.InitSchema();
            }

            var mapper = new AssemblyScanningMappingProvider();

            mapper.Scan(typeof(AccountRepository).Assembly);
            EntityMappingProvider.Provider = mapper;
        }
コード例 #4
0
        public ScanForMappings()
        {
            var provider = new AssemblyScanningMappingProvider();

            provider.Scan(typeof(UserMapper).Assembly);
            EntityMappingProvider.Provider = provider;
        }
コード例 #5
0
        public void throw_on_invalid_mappers()
        {
            var sut = new AssemblyScanningMappingProvider();

            Action actual = () => sut.Scan(Assembly.GetExecutingAssembly());

            actual.Should().Throw <MappingException>();
        }
        public void throw_on_invalid_mappers()
        {
            var sut = new AssemblyScanningMappingProvider();
            
            Action actual = () => sut.Scan(Assembly.GetExecutingAssembly());

            actual.ShouldThrow<MappingException>();
        }
        public void protest_if_there_are_more_than_one_mapper_for_an_entity()
        {
            var sut = new AssemblyScanningMappingProvider();
            sut.IgnoreInvalidMappers = true;

            Action actual = sut.Scan;

            actual.ShouldThrow<MappingException>();
        }
コード例 #8
0
        public static void Main(string[] args)
        {
            ConfigureLog4Net();
            var provider = new AssemblyScanningMappingProvider();

            provider.Scan(typeof(AnalyticsRepository).Assembly);
            EntityMappingProvider.Provider = provider;

            BuildWebHost(args).Run();
        }
コード例 #9
0
        public void protest_if_there_are_more_than_one_mapper_for_an_entity()
        {
            var sut = new AssemblyScanningMappingProvider();

            sut.IgnoreInvalidMappers = true;

            Action actual = sut.Scan;

            actual.Should().Throw <MappingException>();
        }
        public void ignore_mappings_that_are_abstract()
        {
            var sut = new AssemblyScanningMappingProvider();
            sut.IgnoreInvalidMappers = true;
            sut.ReplaceDuplicateMappers = true;
            sut.Scan();

            Action actual = () => sut.Get<ClassThatHaveAnAbstractMapper>();

            actual.ShouldThrow<MappingNotFoundException>();
        }
        public void ignore_mappings_that_are_interfaces()
        {
            var sut = new AssemblyScanningMappingProvider();
            sut.IgnoreInvalidMappers = true;
            sut.ReplaceDuplicateMappers = true;
            sut.Scan();

            Action actual = () => sut.Get<WithInterfaceMapping>();

            actual.ShouldThrow<MappingNotFoundException>();
        }
        public void use_the_ok_mapping()
        {
            var sut = new AssemblyScanningMappingProvider();
            sut.IgnoreInvalidMappers = true;
            sut.ReplaceDuplicateMappers = true;
            sut.Scan();

            var actual = sut.Get<Ok>();

            actual.Should().NotBeNull();
        }
        public void using_the_mapperfor_attribute()
        {
            var sut = new AssemblyScanningMappingProvider();
            sut.IgnoreInvalidMappers = true;
            sut.ReplaceDuplicateMappers = true;
            sut.Scan();

            var actual = sut.Get(typeof(UsingAttribute));

            actual.Should().NotBeNull();
        }
コード例 #14
0
        private void ConfigureStandardSetup()
        {
            var provider = new AssemblyScanningMappingProvider();

            provider.Scan(typeof(UserMapper).Assembly);
            EntityMappingProvider.Provider = provider;

            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            _serviceRunner.Start();
        }
コード例 #15
0
        public void using_the_mapperfor_attribute()
        {
            var sut = new AssemblyScanningMappingProvider();

            sut.IgnoreInvalidMappers    = true;
            sut.ReplaceDuplicateMappers = true;
            sut.Scan();

            var actual = sut.Get(typeof(UsingAttribute));

            actual.Should().NotBeNull();
        }
コード例 #16
0
        public void use_the_ok_mapping()
        {
            var sut = new AssemblyScanningMappingProvider();

            sut.IgnoreInvalidMappers    = true;
            sut.ReplaceDuplicateMappers = true;
            sut.Scan();

            var actual = sut.Get <Ok>();

            actual.Should().NotBeNull();
        }
コード例 #17
0
        public void ignore_mappings_that_are_interfaces()
        {
            var sut = new AssemblyScanningMappingProvider();

            sut.IgnoreInvalidMappers    = true;
            sut.ReplaceDuplicateMappers = true;
            sut.Scan();

            Action actual = () => sut.Get <WithInterfaceMapping>();

            actual.Should().Throw <MappingNotFoundException>();
        }
コード例 #18
0
        public void ignore_mappings_that_are_abstract()
        {
            var sut = new AssemblyScanningMappingProvider();

            sut.IgnoreInvalidMappers    = true;
            sut.ReplaceDuplicateMappers = true;
            sut.Scan();

            Action actual = () => sut.Get <ClassThatHaveAnAbstractMapper>();

            actual.Should().Throw <MappingNotFoundException>();
        }
コード例 #19
0
        public AsyncCommandExtensionsTests()
        {
            CommandBuilderFactory.Assign(mapper => new SqliteCommandBuilder(mapper));
            var provider = new AssemblyScanningMappingProvider();

            provider.Scan(Assembly.GetExecutingAssembly());
            EntityMappingProvider.Provider = provider;
            _dbFile = Path.GetTempFileName();
            var cs = "URI=file:" + _dbFile;

            _connection = new SQLiteConnection(cs);
            _connection.Open();

            _userTable.Create(_connection);
        }