public async void Query2() { var collection = _database.GetCollection<BsonDocument>("restaurants"); var aggregate = collection.Aggregate() .Match(new BsonDocument { { "borough", "Queens" }, { "cuisine", "Brazilian" } }) .Group(new BsonDocument { { "_id", "$address.zipcode" }, { "count", new BsonDocument("$sum", 1) } }); var results = await aggregate.ToListAsync(); var expectedResults = new[] { BsonDocument.Parse("{ _id : '11368', count : 1 }"), BsonDocument.Parse("{ _id : '11106', count : 3 }"), BsonDocument.Parse("{ _id : '11377', count : 1 }"), BsonDocument.Parse("{ _id : '11103', count : 1 }"), BsonDocument.Parse("{ _id : '11101', count : 2 }") }; //results.Should().BeEquivalentTo(expectedResults); //CollectionAssert }
public void PostStatus() { var status = new { Message = new { ErrorPageCount, LeftPageCount, Speed, StartTime, Status, SuccessPageCount, ThreadCount, TotalPageCount }, Name, Machine = Log.Machine, UserId = _userId, TaskGroup = _taskGroup, Timestamp = DateTime.Now }; var task = _client.PostAsync(StatusServer, new StringContent(JsonConvert.SerializeObject(status), Encoding.UTF8, "application/json")); StatusUpLoadTasks.Add(task); task.ContinueWith((t) => { StatusUpLoadTasks.Remove(t); }); }
public void TestServersWithOneServer() { var settings = new MongoServerSettings(); Assert.AreEqual(_localHost, settings.Server); Assert.IsTrue(new[] { _localHost }.SequenceEqual(settings.Servers)); var server = new MongoServerAddress("server"); var servers = new[] { server }; settings.Servers = servers; Assert.AreEqual(server, settings.Server); Assert.IsTrue(servers.SequenceEqual(settings.Servers)); settings.Freeze(); Assert.AreEqual(server, settings.Server); Assert.IsTrue(servers.SequenceEqual(settings.Servers)); Assert.Throws<InvalidOperationException>(() => { settings.Server = server; }); }