Esempio n. 1
0
        static void Main(string[] args)
        {
            var locator = new MongodExeLocator();

            using (var server = MongoTestServer.Start(27017, locator))
            {
            }
        }
            public DisposableDatabase(MongoTestServer mongoTestServer)
            {
                if (mongoTestServer == null)
                {
                    throw new ArgumentNullException(nameof(mongoTestServer));
                }

                _mongoTestServer = mongoTestServer;
            }
        public async Task HasEnoughRating_Should_Throw_InvalidOperationException_When_The_User_Is_Not_Found()
        {
            using (MongoTestServer server = SetupServer())
            {
                // ARRANGE
                var collection = server.Database.GetCollection <UserEntity>("users");
                var service    = new MyCounterService(collection);
                await collection.InsertOneAsync(new UserEntity
                {
                    Id     = ObjectId.GenerateNewId().ToString(),
                    Name   = "foo",
                    Rating = 23
                });

                // ACT, ASSERT
                Assert.Throws <InvalidOperationException>(
                    () => service.HasEnoughRating(ObjectId.GenerateNewId().ToString()));
            }
        }
        public async Task HasEnoughRating_Should_Return_False_When_The_User_Has_100_Rating()
        {
            using (MongoTestServer server = SetupServer())
            {
                // ARRANGE
                var collection = server.Database.GetCollection <UserEntity>("users");
                var service    = new MyCounterService(collection);
                var userId     = ObjectId.GenerateNewId().ToString();
                await collection.InsertOneAsync(new UserEntity
                {
                    Id     = userId,
                    Name   = "foo",
                    Rating = 100
                });

                // ACT
                bool isEnough = service.HasEnoughRating(userId);

                // ASSERT
                Assert.False(isEnough);
            }
        }
 public static DisposableDatabase CreateDatabase() =>
 new DisposableDatabase(MongoTestServer.Setup(27017));
Esempio n. 6
0
 protected MongoTestServer StartServer()
 {
     return(MongoTestServer.Start(Port, new MongodExeLocator()));
 }
Esempio n. 7
0
 protected MongoTestServer SetupServer()
 {
     return(MongoTestServer.Setup(Port));
 }
Esempio n. 8
0
 public MongoConfiguration(string pathToMongoDExe)
 {
     this.mongoServer = new MongoTestServer(TcpPortUtility.GetFreeTcpPort(), pathToMongoDExe);
     this.MongoClient = mongoServer.Database.Client;
 }
Esempio n. 9
0
 public void SetUp()
 {
     _testServer = new MongoTestServer(@"..\..\..\..\tools\mongodb\binaries\mongod", "OrmongoTests");
     _testServer.Start();
 }