Example #1
0
        public void MongoClientAccessorConstror(MongoClient mongoClient, string databaseName)
        {
            var clientAccessor = new MongoClientAccessor(mongoClient, databaseName);

            clientAccessor.MongoClient.Should().Be(mongoClient);
            clientAccessor.DatabaseName.Should().Be(databaseName);
        }
Example #2
0
        internal static Configure InternalMongoPersistence(this Configure config, MongoClientAccessor clientAccessor)
        {
            Contract.Requires(config != null);
            Contract.Requires(clientAccessor != null);

            return(config.InternalMongoPersistence(() =>
            {
                VerifyConnectionToMongoServer(clientAccessor);
                return clientAccessor;
            }));
        }
Example #3
0
        internal static void VerifyConnectionToMongoServer(MongoClientAccessor mongoClientAccessor)
        {
            Contract.Requires(mongoClientAccessor != null);

            var server = mongoClientAccessor.MongoClient.GetServer();

            try
            {
                server.Ping();
            }
            catch (Exception ex)
            {
                ShowUncontactableMongoWarning(mongoClientAccessor.MongoClient, ex);
                return;
            }

            Logger.InfoFormat("Connection to MongoDB at {0} verified.", string.Join(", ", GetMongoServers(mongoClientAccessor.MongoClient)));
        }
Example #4
0
        public void Customize(IFixture fixture)
        {
            var client          = new MongoClient(MongoPersistenceConstants.DefaultConnectionString);
            var clientAccessor  = new MongoClientAccessor(client, "UnitTest");
            var databaseFactory = new MongoDatabaseFactory(clientAccessor);

            fixture.Register(() => client);
            fixture.Register(() => clientAccessor);
            fixture.Register(() => databaseFactory);

            fixture.Customize <TimeoutData>(
                c => c.With(t => t.OwningTimeoutManager, "UnitTests").With(t => t.Time, DateTime.UtcNow));

            fixture.Customize <MongoTimeoutPersister>(c => c.With(t => t.EndpointName, "UnitTests"));

            fixture.Customize(new SupportMutableValueTypesCustomization());

            TimeoutClassMaps.ConfigureClassMaps();
        }
Example #5
0
        public void Customize(IFixture fixture)
        {
            var client          = new MongoClient(MongoPersistenceConstants.DefaultConnectionString);
            var clientAccessor  = new MongoClientAccessor(client, "UnitTest");
            var databaseFactory = new MongoDatabaseFactory(clientAccessor);

            fixture.Register(() => client);
            fixture.Register(() => clientAccessor);
            fixture.Register(() => databaseFactory);
            fixture.Register(() => new ContextBag());
            fixture.Register(
                () => new SagaCorrelationProperty("UniqueProperty", fixture.Create("UniqueProperty")));

            fixture.Customize(new AutoMoqCustomization());

            fixture.Customize <TimeoutData>(
                c => c.With(t => t.OwningTimeoutManager, "UnitTests").With(t => t.Time, DateTime.UtcNow));

            fixture.Register(() => new MongoTimeoutPersister(databaseFactory, "UnitTests"));

            fixture.Customize(new SupportMutableValueTypesCustomization());

            TimeoutClassMaps.ConfigureClassMaps();
        }
        internal static void VerifyConnectionToMongoServer(MongoClientAccessor mongoClientAccessor)
        {
            Contract.Requires(mongoClientAccessor != null);

            var server = mongoClientAccessor.MongoClient.GetServer();

            try
            {
                server.Ping();
            }
            catch (Exception ex)
            {
                ShowUncontactableMongoWarning(mongoClientAccessor.MongoClient, ex);
                return;
            }

            Logger.InfoFormat("Connection to MongoDB at {0} verified.", string.Join(", ", GetMongoServers(mongoClientAccessor.MongoClient)));
        }
        internal static Configure InternalMongoPersistence(this Configure config, MongoClientAccessor clientAccessor)
        {
            Contract.Requires(config != null);
            Contract.Requires(clientAccessor != null);

            return config.InternalMongoPersistence(() =>
            {
                VerifyConnectionToMongoServer(clientAccessor);
                return clientAccessor;
            });
        }