Example #1
0
        public AuthorizeTest()
        {
            var confFileName = Path.Combine(
                Path.GetDirectoryName(GetType().Assembly.Location) ?? string.Empty,
                $"Monica.Crm.WebApi.dll.config");
            var build           = new ConfigurationBuilder().AddXmlFile(confFileName);
            var configiguration = build.Build();

            var files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll");

            foreach (var file in files)
            {
                if (file.IndexOf("testhost.dll", StringComparison.Ordinal) > -1)
                {
                    continue;
                }

                System.Runtime.Loader.AssemblyLoadContext.Default
                .LoadFromAssemblyPath(file);
            }

            AutoFac.Init(DataBaseName.MySql, builder =>
            {
                builder.RegisterInstance(configiguration).As <IConfiguration>();
            });
            _monicaAuthorizeDataAdapter = AutoFac.Resolve <IMonicaAuthorizeDataAdapter>();
        }
        public async Task GetRoles()
        {
            var roleManager = AutoFac.Resolve <RoleManager <ApplicationRole> >();
            var ss          = roleManager.Roles.Select(s => s.Name);

            Assert.IsNotEmpty(ss);
        }
        public async Task ParserRtf_Normal()
        {
            var loaderFile = AutoFac.Resolve <ILoaderFile>();

            foreach (var f in Directory.GetFiles(_pathDir))
            {
                var file = await File.ReadAllBytesAsync(f);

                var fileRtf = await Service.ParseDocument(file);

                var documentLoader = await loaderFile.SaveDocumentLoader(fileRtf);

                await loaderFile.RunAotParser(documentLoader);

                Assert.IsNotNull(fileRtf);
            }
        }
Example #4
0
        protected BaseServiceTest()
        {
            var mockDataBaseMain = new Mock <IDataBaseMain>();
            var mockDataBaseIs4  = new Mock <IDataBaseIs4>();
            var logger           = new Mock <ILogger>();

            var configiguration     = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
            var connectionString    = configiguration.ConnectionStrings.ConnectionStrings["MySqlDatabase"].ConnectionString;
            var connectionStringIs4 = configiguration.ConnectionStrings.ConnectionStrings["MySqlDatabaseIS4"].ConnectionString;

            GlobalSettingsApp.CurrentAppDirectory =
                Path.GetDirectoryName(Assembly.GetAssembly(typeof(BaseEfTest)).Location);
            mockDataBaseMain.Setup(main => main.ConntectionString).Returns(connectionString);
            mockDataBaseIs4.Setup(main => main.ConntectionString).Returns(connectionStringIs4);
            var events   = new OnStartupEvents();
            var services = new ServiceCollection();

            services.AddSingleton(mockDataBaseMain.Object);
            services.AddSingleton(mockDataBaseIs4.Object);
            events.OnConfigureServicesAfterAddMvc(services, null);


            var files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll");

            foreach (var file in files)
            {
                if (file.IndexOf("testhost.dll", StringComparison.Ordinal) > -1)
                {
                    continue;
                }

                System.Runtime.Loader.AssemblyLoadContext.Default
                .LoadFromAssemblyPath(file);
            }

            AutoFac.Init(DataBaseName.MySql, builder =>
            {
                builder.Populate(services);
                builder.RegisterInstance(logger.Object);
                //builder.RegisterInstance(mockDataBaseIs4);
                //builder.RegisterInstance(mockDataBaseMain);
            });
            Service = AutoFac.Resolve <TService>();
        }
Example #5
0
        protected BaseServiceTest()
        {
            var mockDataBaseMain = new Mock <IDataBaseMain>();
            var mockDataBaseIs4  = new Mock <IDataBaseIs4>();
            var logger           = new Mock <ILogger>();

            var configiguration     = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
            var connectionString    = configiguration.ConnectionStrings.ConnectionStrings["MySqlDatabase"].ConnectionString;
            var connectionStringIs4 = configiguration.ConnectionStrings.ConnectionStrings["MySqlDatabaseIS4"].ConnectionString;

            mockDataBaseMain.Setup(main => main.ConntectionString).Returns(connectionString);
            mockDataBaseIs4.Setup(main => main.ConntectionString).Returns(connectionStringIs4);
            var services = new ServiceCollection();

            services.AddSingleton(mockDataBaseMain.Object);
            services.AddSingleton(mockDataBaseIs4.Object);
            services.AddDbContextCore();
            services.AddDbContext <ClientDbContext>(ServiceLifetime.Transient);


            var files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll");

            foreach (var file in files)
            {
                if (file.IndexOf("testhost.dll", StringComparison.Ordinal) > -1)
                {
                    continue;
                }

                System.Runtime.Loader.AssemblyLoadContext.Default
                .LoadFromAssemblyPath(file);
            }

            AutoFac.Init(DataBaseName.MySql, builder =>
            {
                builder.Populate(services);
                builder.RegisterInstance(logger.Object);
            });
            Service = AutoFac.Resolve <TService>();
        }
 //  protected IEnumerable<EncodingWord> _encodingWords;
 public InputLayer()
 {
     _wordDbContext = AutoFac.Resolve <WordDbContext>();
     // _outputCodeWordsArray = outputCodeWords;
 }
Example #7
0
 public EngineParser(List <WordNotPersistent> wordNotPersistents)
 {
     _wordDbContext        = AutoFac.Resolve <WordDbContext>();
     VocalabryFirstBigramm = wordNotPersistents?.Where(f => f.IsFirst);
     VocalabryEndBigramm   = wordNotPersistents?.Where(f => !f.IsFirst);
 }