コード例 #1
0
        /// <summary>
        /// Using static Mapper, uses <see cref="RandomValuesHelper"/> to create a new <typeparamref name="TSource"/> instance,
        /// maps it to a new <typeparamref name="TDestination"/> instance, and
        /// calls <see cref="MapTester{TSource, TDestination}.AssertMappedValues(TSource, TDestination)"/>.
        /// </summary>
        /// <typeparam name="TSource">The type of the source.</typeparam>
        /// <typeparam name="TDestination">The type of the destination.</typeparam>
        /// <param name="mapTester">The <see cref="MapTester{TSource, TDestination}"/>.</param>
        /// <returns>The mapped <typeparamref name="TDestination"/> instance.</returns>
        public static TDestination AssertAutoMappedRandomValues <TSource, TDestination>(
            this MapTester <TSource, TDestination> mapTester)
        {
            var source = new RandomValuesHelper().CreateInstanceWithRandomValues <TSource>();

            return(mapTester.AssertAutoMappedValues(source));
        }
コード例 #2
0
        public void AssertAutoMappedValues_with_IMapper_should_work()
        {
            Source source = new RandomValuesHelper().CreateInstanceWithRandomValues <Source>();
            Dest   dest   = null;

            AssertExceptionNotThrown.WhenExecuting(() =>
                                                   dest = MapTester.ForMap <Source, Dest>().AssertAutoMappedValues(_mapper, source));

            Assert.IsInstanceOfType(dest, typeof(Dest));
            Console.WriteLine(JsonConvert.SerializeObject(dest));
        }
コード例 #3
0
        public void CreateInstanceWithRandomValues_should_work()
        {
            var dummy = new RandomValuesHelper().CreateInstanceWithRandomValues <Dummy>();

            Console.WriteLine(
                JsonConvert.SerializeObject(
                    dummy,
                    new IsoDateTimeConverter {
                DateTimeFormat = "MM/dd/yyyy hh:mm:ss"
            },
                    new StringEnumConverter()));
        }
コード例 #4
0
        public void WithMaximumDepth_should_work()
        {
            var helper = new RandomValuesHelper();

            var result = helper.CreateInstanceWithRandomValues <Depth1>();

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

            result = helper.WithMaximumDepth(3).CreateInstanceWithRandomValues <Depth1>();
            Assert.IsNull(result.Depth2.Depth3.Depth4, $"Maximum depth {helper.MaximumDepth}");

            result = helper.WithMaximumDepth(2).CreateInstanceWithRandomValues <Depth1>();
            Assert.IsNull(result.Depth2.Depth3, $"Maximum depth {helper.MaximumDepth}");

            result = helper.WithMaximumDepth(1).CreateInstanceWithRandomValues <Depth1>();
            Assert.IsNull(result.Depth2, $"Maximum depth {helper.MaximumDepth}");
        }
コード例 #5
0
        public void RandomEnumValue_should_work()
        {
            StringComparison randomValue = new RandomValuesHelper().RandomEnumValue <StringComparison>();

            Assert.IsNotNull(randomValue);
        }
コード例 #6
0
        public void RandomString_with_prefix_should_work()
        {
            string randomValue = new RandomValuesHelper().RandomString("testPrefix");

            StringAssert.StartsWith(randomValue, "testPrefix");
        }
コード例 #7
0
        public void RandomString_should_work()
        {
            string randomValue = new RandomValuesHelper().RandomString();

            Assert.IsNotNull(randomValue);
        }
コード例 #8
0
        public void RandomFloat_should_work()
        {
            float randomValue = new RandomValuesHelper().RandomFloat();

            Assert.IsNotNull(randomValue);
        }
コード例 #9
0
        public void RandomChar_should_work()
        {
            char randomValue = new RandomValuesHelper().RandomChar();

            Assert.IsNotNull(randomValue);
        }
コード例 #10
0
        public void RandomGuid_should_work()
        {
            Guid randomValue = new RandomValuesHelper().RandomGuid();

            Assert.IsNotNull(randomValue);
        }
コード例 #11
0
        public void RandomDouble_should_work()
        {
            double randomValue = new RandomValuesHelper().RandomDouble();

            Assert.IsNotNull(randomValue);
        }
コード例 #12
0
        public void RandomDecimal_should_work()
        {
            decimal randomValue = new RandomValuesHelper().RandomDecimal();

            Assert.IsNotNull(randomValue);
        }
コード例 #13
0
 public void TestInitialize()
 {
     _randomValuesHelper = new RandomValuesHelper();
 }
コード例 #14
0
        public void RandomBool_should_work()
        {
            bool randomValue = new RandomValuesHelper().RandomBool();

            Assert.IsNotNull(randomValue);
        }
コード例 #15
0
        public void RandomInt_should_work()
        {
            int randomValue = new RandomValuesHelper().RandomInt();

            Assert.IsNotNull(randomValue);
        }
コード例 #16
0
        public void RandomByte_should_work()
        {
            byte randomValue = new RandomValuesHelper().RandomByte();

            Assert.IsNotNull(randomValue);
        }
コード例 #17
0
        public void RandomUShort_should_work()
        {
            ushort randomValue = new RandomValuesHelper().RandomUShort();

            Assert.IsNotNull(randomValue);
        }
コード例 #18
0
        public void RandomDateTime_should_work()
        {
            DateTime randomValue = new RandomValuesHelper().RandomDateTime();

            Assert.IsNotNull(randomValue);
        }
コード例 #19
0
 public void TestInitialize()
 {
     _randomValuesHelper = new RandomValuesHelper();
     _source             = _randomValuesHelper.CreateInstanceWithRandomValues <Source>();
     _mapTester          = MapTester.ForMap <Source, Dest>();
 }