Esempio n. 1
0
        public void CreateRandom_InstanceOf_should_work()
        {
            var dummy = CreateRandom.InstanceOf <Dummy>();

            Console.WriteLine(
                JsonConvert.SerializeObject(
                    dummy,
                    Formatting.Indented,
                    new IsoDateTimeConverter {
                DateTimeFormat = "MM/dd/yyyy hh:mm:ss"
            },
                    new StringEnumConverter()));
        }
Esempio n. 2
0
        public void CreateRandom_InstanceOf_with_callback_should_work()
        {
            var dummy = CreateRandom.InstanceOf <Dummy>(x => x.String = "test string");

            Assert.AreEqual("test string", dummy.String);

            Console.WriteLine(
                JsonConvert.SerializeObject(
                    dummy,
                    Formatting.Indented,
                    new IsoDateTimeConverter {
                DateTimeFormat = "MM/dd/yyyy hh:mm:ss"
            },
                    new StringEnumConverter()));
        }
Esempio n. 3
0
        public void CreateRandom_InstanceOf_with_MaximumDepth_should_work()
        {
            int?maximumDepth = null;
            var result       = CreateRandom.InstanceOf <Depth1>(maximumDepth: maximumDepth);

            Assert.IsNotNull(result.Depth2.Depth3.Depth4, "No maximum depth");

            maximumDepth = 3;
            result       = CreateRandom.InstanceOf <Depth1>(maximumDepth: maximumDepth);
            Assert.IsNull(result.Depth2.Depth3.Depth4, $"Maximum depth {maximumDepth}");

            maximumDepth = 2;
            result       = CreateRandom.InstanceOf <Depth1>(maximumDepth: maximumDepth);
            Assert.IsNull(result.Depth2.Depth3, $"Maximum depth {maximumDepth}");

            maximumDepth = 1;
            result       = CreateRandom.InstanceOf <Depth1>(maximumDepth: maximumDepth);
            Assert.IsNull(result.Depth2, $"Maximum depth {maximumDepth}");
        }