Ejemplo n.º 1
0
        public void TestLocalizedUpdate()
        {
            DbTest(database =>
              {
            // Update object
            var cmsHandler = new cms_handler(database);
            var id = Mocks.BsonDocumentMock["_id"].AsObjectId;
            var cmsParameter = new cms_update_parameter
            {
              id = id,
              collection = "entities",
              field = "Motivation",
              language = "DE",
              value = new BsonString("Neue Deutsche Motivation.")
            };
            var cmsResponse = cmsHandler.update(cmsParameter);

            // Check that the update was successful
            Assert.IsTrue(cmsResponse.success);

            // Check that reduced entity has the expected value
            var actual = cmsHandler.getCurrent("entities", id, "DE");
            actual.OrderFields();
            var expected = Mocks.BsonDocumentMock.DeepClone().AsBsonDocument;
            expected = expected.Current("DE").AsBsonDocument;
            expected["Motivation"] = new BsonString("Neue Deutsche Motivation.");
            expected.OrderFields();
            Assert.AreEqual(expected, actual);
              });
        }
Ejemplo n.º 2
0
 public void TestGetCurrent()
 {
     DbTest(database =>
       {
     var cmsHandler = new cms_handler(database);
     var id = Mocks.BsonDocumentMock["_id"].AsObjectId;
     var actual = cmsHandler.getCurrent("entities", id);
     var expected = Mocks.BsonDocumentMock.Current();
     Assert.AreEqual(expected, actual);
       });
 }
Ejemplo n.º 3
0
 public void TestGetField()
 {
     DbTest(database =>
       {
     var cmsHandler = new cms_handler(database);
     var id = Mocks.BsonDocumentMock["_id"].AsObjectId;
     var actual = cmsHandler.getField("entities", id, "LocalizedHistorized");
     actual = actual["LocalizedHistorized"].AsBsonDocument;
     var expected = Mocks.BsonDocumentMock["LocalizedHistorized"];
     Assert.AreEqual(expected, actual);
       });
 }
Ejemplo n.º 4
0
        public void TestRevision()
        {
            DbTest(database =>
              {
            // Update object
            var cmsHandler = new cms_handler(database);
            var id = Mocks.BsonDocumentMock["_id"].AsObjectId;
            var cmsParameter = new cms_update_parameter
            {
              id = id,
              collection = "entities",
              field = "Description",
              value = new BsonString("It is me, Lucas!")
            };
            var cmsResponse = cmsHandler.revise(cmsParameter);

            // Check that the update was successful
            Assert.IsTrue(cmsResponse.success);

            // Check that reduced entity has the expected value
            var actual = cmsHandler.getCurrent("entities", id);
            actual.OrderFields();
            var expected = Mocks.BsonDocumentMock.DeepClone().AsBsonDocument;
            expected = expected.Current().AsBsonDocument;
            expected["Description"] = new BsonString("It is me, Lucas!");
            expected.OrderFields();
            Assert.AreEqual(expected, actual);
              });
        }
Ejemplo n.º 5
0
 public JsonResult Save(cms_save_parameter parameter)
 {
     var connectionString = "mongodb://localhost";
       var client = new MongoClient(connectionString);
       var server = client.GetServer();
       var database = server.GetDatabase("test");
       var cms_handler = new cms_handler(database);
       var response = cms_handler.save(parameter.collectionName, parameter.document);
       var jsonResult = new JsonResult();
       jsonResult.Data = response.ToJson();
       return jsonResult;
 }