Esempio n. 1
0
        public void FromClassContextSimple()
        {
            var simpleContext = ClassContextObjectMother.Create(typeof(object), typeof(string));
            ConcreteMixedTypeAttribute attribute = CreateAttribute(simpleContext);

            var deserializer = new AttributeClassContextDeserializer(attribute.ClassContextData);

            Assert.That(ClassContext.Deserialize(deserializer), Is.EqualTo(simpleContext));
        }
Esempio n. 2
0
        public void FromClassContext_MixinKinds()
        {
            ClassContext context = new ClassContextBuilder(typeof(int))
                                   .AddComposedInterface(typeof(uint))
                                   .AddMixin(typeof(string)).OfKind(MixinKind.Extending)
                                   .AddMixin(typeof(double)).OfKind(MixinKind.Used)
                                   .BuildClassContext();

            ConcreteMixedTypeAttribute attribute = CreateAttribute(context);
            var deserializer = new AttributeClassContextDeserializer(attribute.ClassContextData);

            Assert.That(ClassContext.Deserialize(deserializer), Is.EqualTo(context));
        }
        public void Deserialize()
        {
            var expectedContext = new ClassContext(typeof(BaseType1), new[] { CreateBT1Mixin1Context() }, new[] { typeof(int), typeof(string) });

            var deserializer = MockRepository.GenerateMock <IClassContextDeserializer> ();

            deserializer.Expect(mock => mock.GetClassType()).Return(expectedContext.Type);
            deserializer.Expect(mock => mock.GetMixins()).Return(expectedContext.Mixins);
            deserializer.Expect(mock => mock.GetComposedInterfaces()).Return(expectedContext.ComposedInterfaces);

            var context = ClassContext.Deserialize(deserializer);

            Assert.That(context, Is.EqualTo(expectedContext));
        }
Esempio n. 4
0
        public void FromClassContextComplex()
        {
            ClassContext context = new ClassContextBuilder(typeof(int))
                                   .AddComposedInterface(typeof(uint))
                                   .AddMixin(typeof(string)).WithDependency(typeof(bool))
                                   .AddMixin(typeof(double)).WithDependency(typeof(int))
                                   .BuildClassContext();

            ConcreteMixedTypeAttribute attribute = CreateAttribute(context);

            var deserializer = new AttributeClassContextDeserializer(attribute.ClassContextData);

            Assert.That(ClassContext.Deserialize(deserializer), Is.EqualTo(context));
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the class context describing the target type of this attribute.
        /// </summary>
        /// <returns>A deserialized form of <see cref="ClassContextData"/>.</returns>
        public ClassContext GetClassContext()
        {
            var deserializer = new AttributeClassContextDeserializer(ClassContextData);

            return(ClassContext.Deserialize(deserializer));
        }
Esempio n. 6
0
 public object GetRealValue()
 {
     return(ClassContext.Deserialize(new FlatClassContextDeserializer(_serializedValues)));
 }