public void GetValueByValueTypeTest_Exception()
        {
            var result = MonkeyTestUtils.GetValueByValueType(typeof(TestClassWithChildren), ValueType.RandomObject,
                                                             new Fixture());

            Assert.Null(result);
        }
        public void IsEnumTest()
        {
            var results = MonkeyTestUtils.GetAllPossibleCombinations(new List <Type> {
                typeof(Yolo), typeof(int)
            }, new Fixture()).ToList();

            Assert.Equal(20, results.Count);
            Assert.Equal(20, results.Distinct().Count());
        }
 public void MakeListsNullTest_NullInput()
 {
     Assert.Null(MonkeyTestUtils.MakeListsNull(null));
     Assert.Null(((GenericClass)MonkeyTestUtils.MakeListsNull(new GenericClass())).Payload);
     Assert.NotNull((EmptyClass)MonkeyTestUtils.MakeListsNull(new EmptyClass()));
     Assert.NotNull(
         ((GenericClass)MonkeyTestUtils.MakeListsNull(new GenericClass()
     {
         Payload = new List <string> {
             "a", "b", "c"
         }
     })).Payload);
     Assert.NotNull(MonkeyTestUtils.MakeListsNull(new CuriousGeorge.PocoWrapper <Counter>()));
     Assert.NotNull(MonkeyTestUtils.MakeListsNull(new CuriousGeorge.PocoWrapper <object>()));
     Assert.NotNull(MonkeyTestUtils.MakeListsNull(new CuriousGeorge.PocoWrapper <EmptyClass>()));
 }
        public void GetDataTest()
        {
            var data = MonkeyTestUtils.GetData(new List <Type> {
                typeof(Yolo), typeof(int)
            }, false, new Fixture()).ToList();

            Assert.Equal(5, data.Count);
            Assert.Equal(Yolo.Yo, (Yolo)data.ElementAt(0)[0]);
            Assert.Equal(0, (int)data.ElementAt(0)[1]);
            Assert.Equal(Yolo.Yo, (Yolo)data.ElementAt(1)[0]);
            Assert.Equal(0, (int)data.ElementAt(1)[1]);
            Assert.Equal(Yolo.Low, (Yolo)data.ElementAt(2)[0]);
            Assert.Equal(int.MaxValue, (int)data.ElementAt(2)[1]);
            Assert.Equal(Yolo.Yo, (Yolo)data.ElementAt(3)[0]);
            Assert.Equal(int.MinValue, (int)data.ElementAt(3)[1]);
            Assert.Null(data.ElementAt(4)[0]);
            Assert.Null(data.ElementAt(4)[1]);
        }
Ejemplo n.º 5
0
 public static IEnumerable <object[]> GetData(Type classType, string methodName, bool allPossibleCombinations)
 {
     try
     {
         var methodInfo = classType.GetMethod(methodName,
                                              BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
         var fixture = new Fixture {
             RepeatCount = 3
         };
         fixture.Behaviors.OfType <ThrowingRecursionBehavior>().ToList()
         .ForEach(b => fixture.Behaviors.Remove(b));
         fixture.Behaviors.Add(new OmitOnRecursionBehavior());
         var methodArgumentTypes = methodInfo.GetParameters().Select(x => x.ParameterType).ToList();
         return(MonkeyTestUtils.GetData(methodArgumentTypes, allPossibleCombinations, fixture));
     }
     catch (Exception ex)
     {
         throw new ArgumentException($"Could not find method '{methodName}' on type {classType.FullName}",
                                     nameof(methodName), ex);
     }
 }
Ejemplo n.º 6
0
        public IEnumerable <object[]> GetData(MethodInfo testMethod)
        {
            var methodArgumentTypes = testMethod.GetParameters().Select(x => x.ParameterType).ToList();

            return(MonkeyTestUtils.GetData(methodArgumentTypes, _allPossibleCombinations, _fixture));
        }