Пример #1
0
        public void Must_Support_Primitive_Types()
        {
            var instance = RandomValue.Object <MyClassHasPrimitiveTypes>();

            Assert.AreNotEqual(0, instance.Int32);
            Assert.AreNotEqual(0, instance.Int16);
            Assert.AreNotEqual(0, instance.UInt16);
            Assert.AreNotEqual(0, instance.Int64);
            Assert.AreNotEqual(0, instance.UInt64);
        }
Пример #2
0
        public void If_Property_Has_Already_Value_Do_Not_Change_It()
        {
            var instance = RandomValue.Object <Class_With_Value_Set_In_Constructor>();

            Assert.AreEqual(56, instance.Property_int);
            Assert.AreEqual(78, instance.Property_int_nullable);
            Assert.IsTrue(instance.Property_int_nullable2 != null);

            Assert.IsTrue(instance.Labels != null);
            Assert.AreEqual("Aloha", instance.Labels.A);
            Assert.IsNull(instance.Labels.A2);
        }
Пример #3
0
        public void Must_Support_Circular_Referenced_Types()
        {
            var randomValue = new RandomValue();

            RandomValue.Object <A>();

            var a = RandomValue.Object <A>();

            Assert.IsTrue(a.AList.Count >= 1);

            Assert.IsTrue(a.ReadOnlyList.Count >= 1);
            Assert.IsTrue(a.A2.ReadOnlyList.Count >= 1);

            Assert.IsTrue(a.IReadOnlyCollectionProperty.Count >= 1);

            for (var i = 0; i < 10; i++)
            {
                randomValue.Object(typeof(A));
            }

            Assert.AreEqual(0, randomValue._objectCreationStack.Count);
        }
Пример #4
0
        public void ShouldSupportByteArray()
        {
            var instance = RandomValue.Object <ByteArrayFieldContainer>();

            instance.Bytes.Length.Should().BeGreaterThan(0);
        }
        /// <summary>
        ///     Objects this instance.
        /// </summary>
        public static T Object <T>() where T : new()
        {
            var randomValue = new RandomValue();

            return((T)randomValue.Object(typeof(T)));
        }