public void CorrectlySerializesToBsonString() { var testModel = new TestModel(); testModel._excludedField = "excluded"; testModel._includedField = "included"; testModel.ExcludedRegularProperty = "excluded"; testModel.IncludedRegularProperty = "included"; testModel.ExcludedCatelProperty = "excluded"; testModel.IncludedCatelProperty = "included"; var configuration = new JsonSerializationConfiguration { UseBson = true }; var json = testModel.ToJson(configuration); Assert.IsFalse(json.Contains("Excluded")); }
public void CorrectlySerializesObjectsWithFormattedIndents() { var serviceLocator = ServiceLocator.Default; var serializer = serviceLocator.ResolveType <IJsonSerializer>(); var model = new CustomJsonSerializationModel { FirstName = "Geert" }; var configuration = new JsonSerializationConfiguration { Formatting = Newtonsoft.Json.Formatting.Indented }; var clonedModel = SerializationTestHelper.SerializeAndDeserialize(model, serializer, configuration); // Note: yes, the *model* is serialized, the *clonedModel* is deserialized Assert.IsTrue(model.IsCustomSerialized); Assert.IsTrue(clonedModel.IsCustomDeserialized); Assert.AreEqual(model.FirstName, clonedModel.FirstName); }