コード例 #1
0
    //protected FakeS3Client s3Mock;



    public FileServiceTests(DbUnitTestSearchFixture fixture)
    {
        this.fixture = fixture;
        this.mapper  = fixture.GetService <IMapper>();

        //This client throws exceptions for everything
        //s3Mock = new FakeS3Client();
        s3provider = new S3Provider(); //As is, it will returned NotImplemented for IAmazonS3

        searcher = fixture.GetGenericSearcher();
        writer   = fixture.GetWriter();
        config   = new FileServiceConfig()
        {
            HighQualityResize = false
        };
        service = new FileService(fixture.GetService <ILogger <FileService> >(), fixture.dbFactory, config, s3provider,
                                  new ImageManipulator_Direct(fixture.GetService <ILogger <ImageManipulator_Direct> >()));

        //Always want a fresh database!
        fixture.ResetDatabase();

        //Every test gets their own directory
        config.MainLocation      = Guid.NewGuid().ToString() + "_main";
        config.ThumbnailLocation = Guid.NewGuid().ToString() + "_thumbnails";
        config.TempLocation      = Guid.NewGuid().ToString() + "_temp(quant)";
    }
コード例 #2
0
ファイル: MarkManager.cs プロジェクト: Burion/Dailer
 public MarkManager(IDbWriter <Mark> dbWriter, IDbReader <Mark> dbReader, UserManager <DailerUser> userManager, IHttpContextAccessor httpContextAccessor)
 {
     _dbReader            = dbReader;
     _dbWriter            = dbWriter;
     _userMananager       = userManager;
     _httpContextAccessor = httpContextAccessor;
 }
コード例 #3
0
 public NoteManager(UserManager <DailerUser> userManager, IHttpContextHendler httpContextHendler, IDbReader <Note> dbReader, IDbWriter <Note> dbWriter)
 {
     _userManager        = userManager;
     _httpContextHendler = httpContextHendler;
     _dbReader           = dbReader;
     _dbWriter           = dbWriter;
 }
コード例 #4
0
        public static void Initialize(IDbWriter db)
        {
            var dbConnection = db.Connection;

            dbConnection.Open();

            dbConnection.Execute("PRAGMA read_uncommitted = true;");

            var migrator = DeployChanges.To
                           .SQLiteDatabase(db.Connection.ConnectionString)
                           .WithScriptsAndCodeEmbeddedInAssembly(typeof(Patch1).Assembly, s => s.StartsWith("Zoxive.HttpLoadTesting.Client.Domain.Database.Migrations"))
                           .WithTransaction()
                           .LogToConsole()
                           .Build();

            var wasPatched = migrator.IsUpgradeRequired();

            var result = migrator.PerformUpgrade();

            if (result.Successful && wasPatched)
            {
                db.Connection.Execute("VACUUM");
            }

            if (!result.Successful)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(result.Error);
                Console.ResetColor();

                throw new Exception("Migration Failed");
            }
        }
コード例 #5
0
ファイル: DbImporter.cs プロジェクト: LinqManJr/Korzh.DbUtils
 /// <summary>
 /// Initializes a new instance of the <see cref="DbImporter"/> class.
 /// </summary>
 /// <param name="dbWriter">The database writer - an object which implements <see cref="IDbWriter"/> interface.</param>
 /// <param name="datasetImporter">The dataset importer - knows how to read one dataset data stored in a particular format.</param>
 /// <param name="unpacker">The unpacker - knows how to find the data for a particular dataset "packed" in "archive".</param>
 /// <param name="loggerFactory">The logger factory.</param>
 public DbImporter(IDbWriter dbWriter, IDatasetImporter datasetImporter, IDataUnpacker unpacker, ILoggerFactory loggerFactory = null)
 {
     _dbWriter        = dbWriter;
     _datasetImporter = datasetImporter;
     _dataUnpacker    = unpacker;
     _logger          = loggerFactory?.CreateLogger("Korzh.DbUtils");
 }
コード例 #6
0
 public DatabaseProvider(IThronesDBProvider thronesDbProvider,
                         IDbReader localDbReader,
                         IDbWriter localDbWriter)
 {
     this.thronesDbProvider = thronesDbProvider;
     this.localDbReader     = localDbReader;
     this.localDbWriter     = localDbWriter;
 }
コード例 #7
0
 public ShortcutsServiceTests(DbUnitTestSearchFixture fixture)
 {
     this.fixture = fixture;
     this.writer  = fixture.GetWriter();
     this.search  = fixture.GetGenericSearcher();
     this.mapper  = fixture.GetService <IMapper>();
     this.service = new ShortcutsService(fixture.GetService <ILogger <ShortcutsService> >(), fixture.dbFactory, mapper);
 }
コード例 #8
0
        public FileWorker(DataBase dataBase,
                          IDbWriterFactory dbWriterFactory,
                          ISourceFactory sourceFactory)
        {
            _sourceFactory = sourceFactory;

            DataBase  = dataBase;
            _dbWriter = dbWriterFactory.GetDbWriter(dataBase.Settings.DefaultSource);
        }
コード例 #9
0
        public void Initialize()
        {
            var dbClientFactoryMock = new Mock <IDbClientFactory>();

            _dbClientMock = new Mock <IDbClient>();

            dbClientFactoryMock.Setup(x => x.GetMongoClient(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(_dbClientMock.Object);

            _dbWriter = new MongoDbWriter(dbClientFactoryMock.Object);
        }
コード例 #10
0
    public SpecializedSearchTests(DbUnitTestSearchFixture fixture)
    {
        this.fixture = fixture;
        this.mapper  = fixture.GetService <IMapper>();

        searcher = fixture.GetGenericSearcher(); //GetService<IGenericSearch>();
        writer   = fixture.GetWriter();

        //Always want a fresh database!
        fixture.ResetDatabase();
    }
コード例 #11
0
    public CombinedUserTests(DbUnitTestSearchFixture fixture)
    {
        this.fixture = fixture;
        this.mapper  = fixture.GetService <IMapper>();

        searcher = fixture.GetGenericSearcher();
        writer   = fixture.GetWriter();

        service = fixture.GetService <IUserService>();

        //Always want a fresh database!
        fixture.ResetDatabase();
    }
コード例 #12
0
    public ModuleServiceTests(DbUnitTestSearchFixture fixture)
    {
        this.fixture  = fixture;
        this.writer   = fixture.GetWriter();
        this.searcher = fixture.GetGenericSearcher();

        config = new ModuleServiceConfig()
        {
            ModuleDataConnectionString = "Data Source=moduledata;Mode=Memory;Cache=Shared"
        };

        service          = new ModuleService(config, fixture.GetService <ILogger <ModuleService> >(), fixture.dbFactory);
        masterconnection = new SqliteConnection(config.ModuleDataConnectionString);
        masterconnection.Open();

        fixture.ResetDatabase();
    }
コード例 #13
0
        // TODO would be nice to have a dotnetcore compatible migrator.
        public static void Initialize(IDbWriter db, string @namespace = "main")
        {
            var dbConnection = db.Connection;

            dbConnection.Open();

            dbConnection.Execute("PRAGMA read_uncommitted = true;");

            if (IterationTableExists(dbConnection, @namespace))
            {
                return;
            }

            dbConnection.Execute($"DROP TABLE IF EXISTS {@namespace}.Iteration;");
            dbConnection.Execute($"DROP TABLE IF EXISTS {@namespace}.HttpStatusResult;");

            dbConnection.Execute($@"
CREATE TABLE {@namespace}.Iteration (
    Id         INTEGER PRIMARY KEY AUTOINCREMENT,
    UserNumber INTEGER,
    Iteration  INTEGER,
    StartTick  BIGINT,
    EndTick    BIGINT,
    UserDelay  BIGINT,
    Exception  VARCHAR,
    DidError   BOOLEAN,
    BaseUrl    VARCHAR,
    Elapsed    BIGINT,
    TestName   VARCHAR
);
");

            dbConnection.Execute($@"
CREATE TABLE {@namespace}.HttpStatusResult (
    Id                  INTEGER PRIMARY KEY,
    IterationId         INTEGER,
    Method              VARCHAR,
    ElapsedMilliseconds REAL, 
    RequestUrl          VARCHAR,
    StatusCode          INTEGER,
    RequestStartTick    BIGINT
);
");
        }
コード例 #14
0
 public DeleteModel(IDbWriter writer, IDbReader reader, IUserInfoService db)
 {
     _writer = writer;
     _reader = reader;
     _db     = db;
 }
コード例 #15
0
 public CreateModel(IDbWriter writer, IDbReader reader)
 {
     _writer = writer;
     _reader = reader;
 }
コード例 #16
0
        public static IterationResultRepository CreateIterationResultRepository(string databaseFile, out IDbWriter fileDb)
        {
            var connection = new SqliteConnection($"Data Source={databaseFile};cache=shared");

            fileDb = new Db(connection);

            var fileResultRepository = new IterationResultRepository(fileDb);

            DbInitializer.Initialize(fileDb);

            // Looks like we dont really need this
            //connection.Execute("PRAGMA synchronous = OFF;");
            connection.Execute("PRAGMA journal_mode = MEMORY;");

            return(fileResultRepository);
        }
コード例 #17
0
 public SimpleTransaction(IDbWriter dbConnection)
 {
     _dbConnection = (DbConnection)dbConnection.Connection;
 }
コード例 #18
0
ファイル: TraitService.cs プロジェクト: Burion/Dailer
 public TraitService(IDbWriter <Trait> dbWriter, IDbReader <Trait> dbReader)
 {
     _dbWriter = dbWriter;
     _dbReader = dbReader;
 }
コード例 #19
0
 public CreateModel(IDbWriter db)
 {
     _db = db;
 }
コード例 #20
0
 public IterationResultRepository(IDbWriter dbConnection)
 {
     _dbConnection = (DbConnection)dbConnection.Connection;
 }
コード例 #21
0
ファイル: Edit.cshtml.cs プロジェクト: rkbhowmik/LIA_Project
 public EditModel(IDbReader reader, IDbWriter writer)
 {
     _reader = reader;
     _writer = writer;
 }