public void SetUp()
        {
            BsonClassMapHelper.Clear();

            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;
            _writer = tenant.Container.Resolve<IDocumentWriter>();
        }
        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);
            _projections = tenant.Container.Resolve<ITriggerProjectionsUpdate>();
            _handleWriter = tenant.Container.Resolve<IDocumentWriter>();
            _documentReader = tenant.Container.Resolve<IReader<DocumentDescriptorReadModel, DocumentDescriptorId>>();
        }
        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;
        }
        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());
        }
        public void SetUp()
        {
            var config = new DocumentStoreTestConfiguration(_engineVersion);
            MongoDbTestConnectionProvider.DropTestsTenant();
            config.SetTestAddress(TestConfig.ServerAddress);
            _documentStoreService = new DocumentStoreBootstrapper();
            _documentStoreService.Start(config);
            _documentStoreClient = new DocumentStoreServiceClient(
                TestConfig.ServerAddress,
                TestConfig.Tenant
            );
            _tenant = ContainerAccessor.Instance.Resolve<TenantManager>().Current;
            _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);
        }