Browse Source

Partially implemented ValidateCollectionResult. This command is unusual in that most of the information is returned in one long string (the "result" field). It may or may not be worth it to add code to ValidateCollectionResult to parse the result string and return the contained information.

pull/29/head
rstam 15 years ago
parent
commit
aee079c4d6
  1. 7
      Driver/Core/CommandResults/ValidateCollectionResult.cs
  2. 52
      DriverOnlineTests/Core/CommandResults/ValidateCollectionResultTests.cs
  3. 1
      DriverOnlineTests/DriverOnlineTests.csproj

7
Driver/Core/CommandResults/ValidateCollectionResult.cs

@ -30,6 +30,13 @@ namespace MongoDB.Driver {
#endregion
#region public properties
public string Namespace {
get { return this["ns"].AsString; }
}
public string ResultString {
get { return this["result"].AsString; }
}
#endregion
}
}

52
DriverOnlineTests/Core/CommandResults/ValidateCollectionResultTests.cs

@ -0,0 +1,52 @@
/* Copyright 2010 10gen Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using MongoDB.Driver;
namespace MongoDB.DriverOnlineTests.CommandResults {
[TestFixture]
public class ValidateCollectionResultTests {
private MongoServer server;
private MongoDatabase database;
private MongoCollection<BsonDocument> collection;
[TestFixtureSetUp]
public void Setup() {
server = MongoServer.Create();
database = server["driveronlinetests"];
collection = database["test"];
}
[Test]
public void Test() {
// make sure collection exists and has exactly one document
collection.RemoveAll();
collection.Insert(new BsonDocument());
var result = collection.Validate();
Assert.IsTrue(result.Ok);
Assert.AreEqual("driveronlinetests.test", result.Namespace);
Assert.IsTrue(result.ResultString.Length > 0);
}
}
}

1
DriverOnlineTests/DriverOnlineTests.csproj

@ -76,6 +76,7 @@
<Compile Include="Core\CommandResults\CommandResultTests.cs" />
<Compile Include="Core\CommandResults\DatabaseStatsResultTests.cs" />
<Compile Include="Core\CommandResults\GetLastErrorResultTests.cs" />
<Compile Include="Core\CommandResults\ValidateCollectionResultTests.cs" />
<Compile Include="Core\MongoCollectionTests.cs" />
<Compile Include="Core\MongoDatabaseTests.cs" />
<Compile Include="Core\MongoServerTests.cs" />

Loading…
Cancel
Save