예제 #1
0
        public void TrainGraphAxisTickInfoExtensionsClass_PopulateSizeMethod_ThrowsArgumentNullException_IfSecondParameterIsNull()
        {
            TrainGraphAxisTickInfo testObject = GetTickInfo();
            IGraphicsContext       testParam1 = null;
            IFontDescriptor        testParam2 = new Mock <IFontDescriptor>().Object;

            testObject.PopulateSize(testParam1, testParam2);

            Assert.Fail();
        }
        public void TrainGraphAxisTickInfoExtensionsClass_PopulateSizeMethod_ThrowsArgumentNullException_IfSecondParameterIsNull()
        {
            TrainGraphAxisTickInfo testObject = GetTrainGraphAxisTickInfo();
            Graphics testParam1 = null;

            using (Font testParam2 = new Font("Arial", 10))
            {
                testObject.PopulateSize(testParam1, testParam2);

                Assert.Fail();
            }
        }
        public void TrainGraphAxisTickInfoExtensionsClass_PopulateSizeMethod_ThrowsArgumentNullException_IfFirstParameterIsNull()
        {
            TrainGraphAxisTickInfo testObject = null;

            using (Font testParam2 = new Font("Arial", 10))
                using (Bitmap dummyBitmap = new Bitmap(1, 1))
                {
                    Graphics testParam1 = Graphics.FromImage(dummyBitmap);

                    testObject.PopulateSize(testParam1, testParam2);

                    Assert.Fail();
                }
        }
        /// <summary>
        /// Populate the <see cref="TrainGraphAxisTickInfo.Width"/> and <see cref="TrainGraphAxisTickInfo.Height"/> properties.
        /// </summary>
        /// <param name="tickInfo">The tick object to populate.</param>
        /// <param name="graphicsContext">The <see cref="Graphics"/> object used to measure the tick's label.</param>
        /// <param name="font">The font used to measure the tick's label.</param>
        public static void PopulateSize(this TrainGraphAxisTickInfo tickInfo, Graphics graphicsContext, Font font)
        {
            if (tickInfo is null)
            {
                throw new ArgumentNullException(nameof(tickInfo));
            }
            if (graphicsContext is null)
            {
                throw new ArgumentNullException(nameof(graphicsContext));
            }

            SizeF size = graphicsContext.MeasureString(tickInfo.Label, font);

            tickInfo.Width  = size.Width;
            tickInfo.Height = size.Height;
        }
        public static void PopulateSize(this TrainGraphAxisTickInfo tickInfo, IGraphicsContext context, IFontDescriptor font)
        {
            if (tickInfo is null)
            {
                throw new ArgumentNullException(nameof(tickInfo));
            }
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            UniSize measure = context.MeasureString(tickInfo.Label, font);

            tickInfo.Width  = measure.Width;
            tickInfo.Height = measure.Height;
        }
예제 #6
0
        public void TrainGraphAxisTickInfoExtensionsClass_PopulateSizeMethod_ThrowsArgumentNullExceptionWithCorrectParamNameProperty_IfSecondParameterIsNull()
        {
            TrainGraphAxisTickInfo testObject = GetTickInfo();
            IGraphicsContext       testParam1 = null;
            IFontDescriptor        testParam2 = new Mock <IFontDescriptor>().Object;

            try
            {
                testObject.PopulateSize(testParam1, testParam2);
                Assert.Fail();
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("context", ex.ParamName);
            }
        }
        public void TrainGraphAxisTickInfoExtensionsClass_PopulateSizeMethod_ThrowsArgumentNullExceptionWithCorrectParamNameProperty_IfSecondParameterIsNull()
        {
            TrainGraphAxisTickInfo testObject = GetTrainGraphAxisTickInfo();
            Graphics testParam1 = null;

            using (Font testParam2 = new Font("Arial", 10))
            {
                try
                {
                    testObject.PopulateSize(testParam1, testParam2);
                    Assert.Fail();
                }
                catch (ArgumentNullException ex)
                {
                    Assert.AreEqual("graphicsContext", ex.ParamName);
                }
            }
        }
        public void TrainGraphAxisTickInfoExtensionsClass_PopulateSizeMethod_ThrowsArgumentNullExceptionWithCorrectParamNameProperty_IfFirstParameterIsNull()
        {
            TrainGraphAxisTickInfo testObject = null;

            using (Font testParam2 = new Font("Arial", 10))
                using (Bitmap dummyBitmap = new Bitmap(1, 1))
                {
                    Graphics testParam1 = Graphics.FromImage(dummyBitmap);

                    try
                    {
                        testObject.PopulateSize(testParam1, testParam2);
                        Assert.Fail();
                    }
                    catch (ArgumentNullException ex)
                    {
                        Assert.AreEqual("tickInfo", ex.ParamName);
                    }
                }
        }