public void Serialization_SimpleObject() { var id = new Guid("452EED4D-F32D-4A2A-8509-3555F860DACB"); var compositeObjectTypeId = new Guid(CompositeObjectTestData.StaticCompositeObjectTypeId); var simpleObjectTypeId = new Guid(CompositeObjectTestData.StaticSimpleObjectTypeId); Guid?parentId = new Guid("3D73633B-2ABF-4210-9227-0B2FA626E6E6"); var userId = new Guid("35BC092C-F443-4E41-A199-A89475C496A6"); var changeSetId = new Guid("65ABF599-10D1-41DD-90B4-EAB1B0691881"); var stringAttribute = new AttributeDefinition("StringAttribute", typeof(string), new StringSerializer()); const string stringAttributeValue = "TEST"; var int32Attribute = new AttributeDefinition("Int32Attribute", typeof(Int32), new Int32Serializer()); const int int32AttributeValue = Int32.MaxValue; var simpleObjectAttributes = new Dictionary <AttributeDefinition, object> { { stringAttribute, stringAttributeValue }, { int32Attribute, int32AttributeValue } }; var simpleObjectDefinition = new SimpleObjectDefinition(simpleObjectTypeId, new[] { stringAttribute, int32Attribute }); RegisterStrictMock <IBusinessObjectDefinitionProvider>() .Expect(e => e.FindSimpleObjectDefinition(compositeObjectTypeId, simpleObjectTypeId)) .Return(simpleObjectDefinition); var simpleObject = new SimpleObject(id, parentId, simpleObjectAttributes, simpleObjectDefinition, userId, new DateTimeOffset(), changeSetId); var serializedObject = simpleObject.Serialize(); var businessObjectDefinitionProvider = Resolve <IBusinessObjectDefinitionProvider>(); var deserializedObject = new SimpleObject(serializedObject, businessObjectDefinitionProvider, compositeObjectTypeId); Assert.AreEqual(simpleObject.Id, deserializedObject.Id); Assert.AreEqual(simpleObject.SimpleObjectTypeId, deserializedObject.SimpleObjectTypeId); Assert.AreEqual(simpleObject.ParentId, deserializedObject.ParentId); Assert.AreEqual(simpleObject.Revision, deserializedObject.Revision); Assert.AreEqual(simpleObject.Attributes.Count, deserializedObject.Attributes.Count); Assert.IsTrue(deserializedObject.Attributes.ContainsKey(stringAttribute)); Assert.AreEqual(simpleObject.Attributes[stringAttribute], deserializedObject.Attributes[stringAttribute]); Assert.IsTrue(deserializedObject.Attributes.ContainsKey(int32Attribute)); Assert.AreEqual(simpleObject.Attributes[int32Attribute], deserializedObject.Attributes[int32Attribute]); }