Exemplo n.º 1
0
        public void Serialize_PassesPropertyToEnumSerializer()
        {
            var sampleProperty     = GetPropertyDefinition((ClassWithAllDataTypes _) => _.EnumProperty);
            var enumSerializerMock = MockRepository.GenerateMock <IEnumSerializer>();
            var enumPropertySerializerDecorator = new EnumPropertySerializerDecorator(enumSerializerMock, MockRepository.GenerateStub <IPropertySerializer>());

            enumSerializerMock.Expect(_ => _.CollectPropertyType(sampleProperty));
            enumSerializerMock.Replay();

            enumPropertySerializerDecorator.Serialize(
                sampleProperty,
                MockRepository.GenerateStub <IRdbmsPersistenceModelProvider>());

            enumSerializerMock.VerifyAllExpectations();
        }
Exemplo n.º 2
0
        public void Serialize_DelegatesToPropertySerializer()
        {
            var sampleProperty                  = GetPropertyDefinition((ClassWithAllDataTypes _) => _.ExtensibleEnumProperty);
            var propertySerializerMock          = MockRepository.GenerateMock <IPropertySerializer>();
            var enumPropertySerializerDecorator = new EnumPropertySerializerDecorator(MockRepository.GenerateStub <IEnumSerializer>(), propertySerializerMock);

            var expected = new XElement("expected");

            propertySerializerMock.Expect(
                _ => _.Serialize(Arg.Is(sampleProperty), Arg <IRdbmsPersistenceModelProvider> .Is.Anything))
            .Return(expected);

            propertySerializerMock.Replay();

            var actual = enumPropertySerializerDecorator.Serialize(
                sampleProperty,
                MockRepository.GenerateStub <IRdbmsPersistenceModelProvider>());

            propertySerializerMock.VerifyAllExpectations();

            Assert.That(actual, Is.SameAs(expected));
        }