public void SetUp()
        {
            var config = new DocumentStoreTestConfiguration();

            MongoDbTestConnectionProvider.DropTestsTenant();
            config.SetTestAddress(TestConfig.ServerAddress);
            _documentStoreService = new DocumentStoreBootstrapper();
            _documentStoreService.Start(config);

            TenantContext.Enter(new TenantId(TestConfig.Tenant));
            var tenant = ContainerAccessor.Instance.Resolve <TenantManager>().Current;

            _bus       = tenant.Container.Resolve <ICommandBus>();
            _filestore = tenant.Container.Resolve <IBlobStore>();
            Assert.IsTrue(_bus is IInProcessCommandBus);

            //Issue: https://github.com/ProximoSrl/Jarvis.DocumentStore/issues/26
            //you need to resolve the IReader that in turns resolves the ProjectionEngine, becauase if you
            //directly resolve the ITriggerProjectionsUpdate, projection engine will be resolved multiple times.
            tenant.Container.Resolve <IReader <StreamReadModel, Int64> >();
            _projections = tenant.Container.Resolve <ITriggerProjectionsUpdate>();

            _handleWriter   = tenant.Container.Resolve <IDocumentWriter>();
            _documentReader = tenant.Container.Resolve <IReader <DocumentDescriptorReadModel, DocumentDescriptorId> >();
        }
示例#2
0
        public void SetUp()
        {
            var config = new DocumentStoreTestConfiguration(_engineVersion);

            MongoDbTestConnectionProvider.DropTestsTenant();
            config.SetTestAddress(TestConfig.TestHostServiceAddress);
            _documentStoreService = new DocumentStoreBootstrapper();
            _documentStoreService.Start(config);
            _documentStoreClient = new DocumentStoreServiceClient(
                TestConfig.ServerAddress,
                TestConfig.Tenant
                );
            _tenant = ContainerAccessor.Instance.Resolve <TenantManager>().GetTenant(new TenantId(TestConfig.Tenant));

            //Issue: https://github.com/ProximoSrl/Jarvis.DocumentStore/issues/26
            //you need to resolve the IReader that in turns resolves the ProjectionEngine, becauase if you
            //directly resolve the ITriggerProjectionsUpdate, projection engine will be resolved multiple times.
            _tenant.Container.Resolve <IReader <StreamReadModel, Int64> >();
            _projections = _tenant.Container.Resolve <ITriggerProjectionsUpdate>();

            _documentDescriptorCollection = MongoDbTestConnectionProvider.ReadModelDb.GetCollection <DocumentDescriptorReadModel>("rm.DocumentDescriptor");
            _documentCollection           = MongoDbTestConnectionProvider.ReadModelDb.GetCollection <DocumentReadModel>("rm.Document");
            _commitCollection             = MongoDbTestConnectionProvider.ReadModelDb.GetCollection <BsonDocument>("Commits");
            _blobStore = _tenant.Container.Resolve <IBlobStore>();

            MongoFlatMapper.EnableFlatMapping(true);
        }
        public void SetUp()
        {
            longFolderName = Path.Combine(Path.GetTempPath(), new String('a', 230));

            _blobId       = new BlobId(_originalFormat, 1);
            _pathToTask   = Path.Combine(longFolderName, "File_1.dsimport");
            _fileToImport = Path.Combine(longFolderName, "A Word Document.docx");
            _fileUri      = new Uri(Path.Combine(longFolderName, "A word document.docx"));

            ClearQueueTempFolder();
            Directory.CreateDirectory(longFolderName);

            File.Copy(Path.Combine(TestConfig.DocumentsFolder, "Queue\\File_1.dsimport"), _pathToTask);
            File.Copy(TestConfig.PathToWordDocument, _fileToImport);
            var accessor = Substitute.For <ITenantAccessor>();
            var tenant   = Substitute.For <ITenant>();

            tenant.Id.Returns(new TenantId("tests"));
            var container = Substitute.For <IWindsorContainer>();

            _commandBus = Substitute.For <ICommandBus>();
            var identityGenerator = Substitute.For <IIdentityGenerator>();

            _blobstore = Substitute.For <IBlobStore>();
            _blobstore.Upload(Arg.Is(_originalFormat), Arg.Any <string>()).Returns(_blobId);
            _blobstore.Upload(Arg.Is(_originalFormat), Arg.Any <FileNameWithExtension>(), Arg.Any <Stream>()).Returns(_blobId);

            accessor.GetTenant(_testTenant).Returns(tenant);
            accessor.Current.Returns(tenant);
            tenant.Container.Returns(container);

            container.Resolve <IBlobStore>().Returns(_blobstore);
            container.Resolve <IIdentityGenerator>().Returns(identityGenerator);
            container.Resolve <IMongoDatabase>().Returns(MongoDbTestConnectionProvider.ReadModelDb);
            var collection = MongoDbTestConnectionProvider.ReadModelDb.GetCollection <ImportFailure>("sys.importFailures");

            collection.Drop();
            DocumentStoreTestConfiguration config = new DocumentStoreTestConfiguration(tenantId: "tests");

            config.SetFolderToMonitor(longFolderName);
            var sysDb = config.TenantSettings.Single(t => t.TenantId == "tests").Get <IMongoDatabase>("system.db");

            sysDb.Drop();
            _queue = new ImportFormatFromFileQueue(config, accessor, _commandBus)
            {
                Logger = new ConsoleLogger()
            };

            _queue.DeleteTaskFileAfterImport = false;
        }
示例#4
0
        public void SetUp()
        {
            BsonClassMapHelper.Clear();

            var config = new DocumentStoreTestConfiguration();

            MongoDbTestConnectionProvider.DropTestsTenant();
            config.SetTestAddress(TestConfig.TestHostServiceAddress);
            _documentStoreService = new DocumentStoreBootstrapper();
            _documentStoreService.Start(config);

            TenantContext.Enter(new TenantId(TestConfig.Tenant));
            var tenant = ContainerAccessor.Instance.Resolve <TenantManager>().Current;

            _writer = tenant.Container.Resolve <IDocumentWriter>();
        }
        public void SetUp()
        {
            BlobStore             = Substitute.For <IBlobStore>();
            IdentityGenerator     = Substitute.For <IIdentityGenerator>();
            _handleWriter         = Substitute.For <IDocumentWriter>();
            DocumentReader        = Substitute.For <IMongoDbReader <DocumentDescriptorReadModel, DocumentDescriptorId> >();
            DocumentDeletedReader = Substitute.For <IMongoDbReader <DocumentDeletedReadModel, String> >();

            QueueDispatcher = Substitute.For <IQueueManager>();
            CounterService  = Substitute.For <ICounterService>();
            var bus           = Substitute.For <IInProcessCommandBus>();
            var configuration = new DocumentStoreTestConfiguration();

            Controller = new DocumentsController(
                BlobStore,
                configuration,
                IdentityGenerator,
                DocumentReader,
                DocumentDeletedReader,
                bus,
                _handleWriter,
                QueueDispatcher,
                CounterService,
                null)
            {
                Request = new HttpRequestMessage
                {
                    RequestUri = new Uri("http://localhost/api/products")
                },
                Logger         = new ConsoleLogger(),
                Configuration  = new HttpConfiguration(),
                RequestContext =
                {
                    RouteData = new HttpRouteData(
                        route: new HttpRoute(),
                        values: new HttpRouteValueDictionary {
                        { "controller", "file" }
                    })
                }
            };

            //  Controller.Configuration.MapHttpAttributeRoutes();

            Controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
        }