Ejemplo n.º 1
0
        public void GetClassContextSimple()
        {
            var simpleContext = ClassContextObjectMother.Create(typeof(object), typeof(string));
            ConcreteMixedTypeAttribute attribute = CreateAttribute(simpleContext);
            ClassContext regeneratedContext      = attribute.GetClassContext();

            Assert.That(simpleContext, Is.EqualTo(regeneratedContext));
            Assert.That(simpleContext, Is.Not.SameAs(regeneratedContext));
        }
Ejemplo n.º 2
0
        public void AttributeWithGenericType()
        {
            ClassContext context = ClassContextObjectMother.Create(typeof(List <>)).SpecializeWithTypeArguments(new[] { typeof(int) });

            Assert.That(context.Type, Is.EqualTo(typeof(List <int>)));
            ConcreteMixedTypeAttribute attribute = CreateAttribute(context);

            ClassContext regeneratedContext = attribute.GetClassContext();

            Assert.That(regeneratedContext.Type, Is.EqualTo(typeof(List <int>)));
        }
Ejemplo n.º 3
0
        public void GetClassContext_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);
            ClassContext regeneratedContext      = attribute.GetClassContext();

            Assert.That(regeneratedContext.Mixins[typeof(string)].MixinKind, Is.EqualTo(MixinKind.Extending));
            Assert.That(regeneratedContext.Mixins[typeof(double)].MixinKind, Is.EqualTo(MixinKind.Used));
        }
Ejemplo n.º 4
0
        public void GetClassContextComplex()
        {
            ClassContext context = new ClassContextBuilder(typeof(int))
                                   .AddMixin(typeof(double))
                                   .AddComposedInterface(typeof(uint))
                                   .AddMixin(typeof(string)).WithDependency(typeof(bool))
                                   .BuildClassContext();

            ConcreteMixedTypeAttribute attribute = CreateAttribute(context);
            ClassContext regeneratedContext      = attribute.GetClassContext();

            Assert.That(context, Is.EqualTo(regeneratedContext));
            Assert.That(context, Is.Not.SameAs(regeneratedContext));
        }
Ejemplo n.º 5
0
        public void GetClassContext_Dependencies()
        {
            ClassContext context = new ClassContextBuilder(typeof(int))
                                   .AddMixin(typeof(object)).OfKind(MixinKind.Extending).WithDependencies(typeof(double), typeof(bool))
                                   .AddMixin(typeof(string)).OfKind(MixinKind.Extending).WithDependencies(typeof(bool))
                                   .AddMixin(typeof(int)).OfKind(MixinKind.Extending)
                                   .BuildClassContext();

            ConcreteMixedTypeAttribute attribute = CreateAttribute(context);
            ClassContext regeneratedContext      = attribute.GetClassContext();

            Assert.That(regeneratedContext.Mixins.Count, Is.EqualTo(3));

            Assert.That(regeneratedContext.Mixins[typeof(object)].ExplicitDependencies, Is.EqualTo(new object[] { typeof(double), typeof(bool) }));
            Assert.That(regeneratedContext.Mixins[typeof(string)].ExplicitDependencies, Is.EqualTo(new object[] { typeof(bool) }));
            Assert.That(regeneratedContext.Mixins[typeof(int)].ExplicitDependencies, Is.Empty);
        }