Exemple #1
0
        public void ForciblyNew_should_throw_ArgumentNullException_if_null_is_passed_as_t()
        {
            // Arrange
            // nop

            // Act, Assert
            Assert.Throws <ArgumentNullException>(() => TypeMixin.ForciblyNew(null, new object[0]));
        }
Exemple #2
0
        public void ForciblyNew_should_return_struct_instance_even_if_NonPublic()
        {
            // Arrange
            // nop

            // Act
            var actual = TypeMixin.ForciblyNew <StructWithNonPublicConstructor>(42d);

            // Assert
            Assert.AreEqual(42d, actual.Value);
        }
Exemple #3
0
        public void ForciblyNew_should_return_null_if_specified_signature_constructor_does_not_exist_against_a_struct()
        {
            // Arrange
            // nop

            // Act
            var actual = TypeMixin.ForciblyNew <StructWithNonPublicConstructor>(42m);

            // Assert
            Assert.AreEqual(default(StructWithNonPublicConstructor), actual);
        }
Exemple #4
0
        public void ForciblyNew_should_return_class_instance_even_if_NonPublic()
        {
            // Arrange
            // nop

            // Act
            var actual = TypeMixin.ForciblyNew <ClassWithNonPublicConstructor>();

            // Assert
            Assert.IsNotNull(actual);
        }
 public void AddMixin(TypeMixin mixin)
 {
     typeMixins.Add(mixin);
     foreach (MethodMixin mm in mixin.Mixins)
     {
         if (!mixins.TryGetValue(mm.Signature, out List <Action <MethodDef> > actions))
         {
             mixins.Add(mm.Signature, actions = new List <Action <MethodDef> >());
         }
         actions.Add(mm.Mixin);
     }
 }