예제 #1
0
 public ValidRdfParseTests(ParseFileTestFixture fixture)
 {
     //_fixture = fixture;
     _blobStorage = fixture.BlobStorage;
     _harness     = new InMemoryTestHarness();
     _consumer    = _harness.Consumer(() => new ParseFileCommandHandler(fixture.BlobStorage));
 }
예제 #2
0
        public ValidCifParseTests(ParseFileTestFixture fixture)
        {
            _blobStorage = fixture.BlobStorage;
            var settings = ConfigurationManager.AppSettings.TestHarnessSettings();

            _harness             = new InMemoryTestHarness();
            _harness.TestTimeout = TimeSpan.FromSeconds(settings.Timeout);
            _consumer            = _harness.Consumer(() => new ParseFileCommandHandler(fixture.BlobStorage));
        }
예제 #3
0
파일: FileTests.cs 프로젝트: xlgwr/osdr
        public FileTests(IndexingFixture indexingFixture)
        {
            _fileId     = Guid.NewGuid();
            index       = string.Empty;
            type        = string.Empty;
            doc         = null;
            docAsUpsert = null;
            string _someField = Guid.NewGuid().ToString();
            string _someValue = Guid.NewGuid().ToString();

            _fakeIndex = new List <IIndexRequest <dynamic> >();
            _mongoDb   = indexingFixture.MongoDb;
            var files = _mongoDb.GetCollection <BsonDocument>("Files");

            files.InsertOne(
                new BsonDocument("_id", _fileId)
                .Add("Name", "Processed.mol")
                .Add("Status", "Processed")
                .Add(_someField, _someValue));

            var list = new List <BsonDocument>();

            for (int i = 0; i < 10; i++)
            {
                list.Add(new BsonDocument("_id", Guid.NewGuid()).Add("Name", i.ToString()));
            }

            files.InsertMany(list);
            _file = _mongoDb.GetCollection <dynamic>("Files").Find(new BsonDocument("_id", _fileId)).First();
            ((IDictionary <string, object>)_file).Remove("_id");
            ((IDictionary <string, object>)_file).Add("id", _fileId);

            _elasticClientMock = new Mock <IElasticClient>();
            _elasticClientMock
            .Setup(m => m.IndexAsync <object>(It.IsAny <IIndexRequest>(), null, default(CancellationToken)))
            .Returns(Task.FromResult(new Mock <IIndexResponse>().Object))
            .Callback <IIndexRequest <object>, Func <IndexDescriptor <object>, IIndexRequest>, CancellationToken>((a, s, c) => {
                _fakeIndex.Add(a);
                index = a.Index.Name;
                type  = a.Type.Name;
            }).Verifiable();

            _elasticClientMock.Setup(m => m.UpdateAsync <object, object>(It.IsAny <IUpdateRequest <object, object> >(), default(CancellationToken)))
            .Returns(Task.FromResult(new Mock <IUpdateResponse <object> >().Object))
            .Callback <IUpdateRequest <object, object>, CancellationToken>((a, c) =>
            {
                index       = a.Index.Name;
                type        = a.Type.Name;
                docAsUpsert = a.DocAsUpsert;
                doc         = a.Doc as IDictionary <string, object>;
            }).Verifiable();

            _harness  = new InMemoryTestHarness();
            _consumer = _harness.Consumer(() => new FileEventHandler(_elasticClientMock.Object, _mongoDb, _blobStorage));

            _harness.Start().Wait();
        }
예제 #4
0
        public RecordTests(IndexingFixture fixture)
        {
            _fixture  = fixture;
            _recordId = Guid.NewGuid();
            _fixture.FakeIndex.Clear();

            string _someField = Guid.NewGuid().ToString();
            string _someValue = Guid.NewGuid().ToString();

            var records = _fixture.MongoDb.GetCollection <BsonDocument>("Records");


            records.InsertOne(
                new BsonDocument("_id", _recordId)
                .Add("Name", "TestName1")
                .Add("Status", "Processed")
                .Add(_someField, _someValue)
                );



            var list = new List <BsonDocument>();

            for (int i = 0; i < 10; i++)
            {
                list.Add(new BsonDocument("_id", Guid.NewGuid()).Add("name", i.ToString()));
            }

            records.InsertMany(list);
            _record = _fixture.MongoDb.GetCollection <dynamic>("Records").Find(new BsonDocument("_id", _recordId)).First();
            ((IDictionary <string, object>)_record).Remove("_id");
            ((IDictionary <string, object>)_record).Add("id", _recordId);



            _harness  = new InMemoryTestHarness();
            _consumer = _harness.Consumer(() => new RecordEventHandler(fixture.ElasticClientMock.Object, fixture.MongoDb));
            _harness.Start().Wait();
        }
예제 #5
0
 public Using_a_consumer_test_harness()
 {
     _consumer = BusTestHarness.Consumer <MyConsumer>();
 }