Пример #1
0
        public UnitTestHelpers()
        {
            _configPath = DirectoryLocator.GetTargetConfigurationPath();
            var msSqlPath = Path.Combine(DirectoryLocator.GetTargetProjectPath(typeof(Program)), @"..\..\MsSqlDb");

            // For the unit tests we
            _tenantContext = new TenantContext
            {
                DbContext =
                {
                    Catalog       = "LeagueIntegration",
                    Schema        = "dbo",
                    ConnectionKey = "dummy"
                }
            };
            _tenantContext.DbContext.ConnectionString =
                $"Server=(LocalDB)\\MSSQLLocalDB;AttachDbFilename={msSqlPath}\\LeagueIntegrationTest.mdf;Database={_tenantContext.DbContext.Catalog};Integrated Security=true";

            // Make sure we can connect to the database
            using (var connection = new Microsoft.Data.SqlClient.SqlConnection(_tenantContext.DbContext.ConnectionString))
                try
                {
                    connection.Open();
                }
                finally
                {
                    connection.Close();
                }

            InitializeLlBlGenPro();
        }
Пример #2
0
        public async Task Create_Should_Work_With_PhysicalFileProvider()
        {
            var localizedTemplateContentReaderFactory = new LocalizedTemplateContentReaderFactory(
                new TestPhysicalVirtualFileProvider(
                    new PhysicalFileProvider(Path.Combine(DirectoryLocator.GetTargetProjectPath(typeof(ServiceSetup)), "Templates"))));

            var reader = await localizedTemplateContentReaderFactory.CreateAsync(_templateDefinitionManager.Get(Templates.WelcomeEmail) !);

            Assert.AreEqual(reader.GetContent("en"), "Welcome {{model.name}} to Axuno.TextTemplating!");
            Assert.AreEqual(reader.GetContent("de"), "Willkommen, {{model.name}}, bei Axuno.TextTemplating!");
        }
        public UnitTestHelpers()
        {
            _configPath = DirectoryLocator.GetTargetConfigurationPath();
            var orgSiteList   = SiteList.DeserializeFromFile(Path.Combine(_configPath, "SiteList.Development.config"));
            var dbContextList = DbContextList.DeserializeFromFile(Path.Combine(_configPath, "DbContextList.Development.config"));

            foreach (var dbContext in dbContextList)
            {
                dbContext.Catalog = "LeagueIntegration";
                var msSqlPath = Path.Combine(DirectoryLocator.GetTargetProjectPath(), @"..\..\MsSqlDb");
                dbContext.ConnectionString = string.Format("Server={0};Database={1};Integrated Security=true", $"(LocalDB)\\MSSQLLocalDB;AttachDbFilename={msSqlPath}\\LeagueIntegrationTest.mdf", dbContext.Catalog);
            }
            var dbContextResolver = new DbContextResolver(dbContextList);

            InitializeLlBlGenPro();

            _siteContext = new SiteContext(dbContextResolver.Resolve("dbo").OrganizationKey, new OrganizationContextResolver(dbContextResolver, new NullLogger <OrganizationContextResolver>(), _configPath), orgSiteList);
        }