public void Given_Rectangle_null_When_ComputeArea_Then_NullReferenceException()
        {
            Rectangle          input     = null;
            RectangleOperation operation = new RectangleOperation();

            operation.Target = input;
            int actual = operation.ComputeArea();
        }
        public static RectangleOperation GetRectangleOperation()
        {
            IUnityContainer container = new UnityContainer();

            container.RegisterType <IRectangleOperation, RectangleOperation>();
            RectangleOperation rectangleOperation = container.Resolve <RectangleOperation>();

            return(rectangleOperation);
        }
Ejemplo n.º 3
0
        public static RectangleOperation GetRectagleOperation()
        {
            UnityContainer unityContainer = new UnityContainer();

            unityContainer.RegisterType <IRectangleOperation, RectangleOperation>();
            RectangleOperation rectangleOperation = unityContainer.Resolve <RectangleOperation>();

            return(rectangleOperation);
            //throw new NotImplementedException();
        }
Ejemplo n.º 4
0
        public void Given_Rectangle_width_5_height_5_when_computerarea2_then_25()
        {
            double    expected = 20;
            Rectangle input    = new Rectangle();

            input.width  = 5;
            input.height = 5;
            RectangleOperation operation = new RectangleOperation();

            operation.Target = input;
        }
        public void Given_Rectangle_Width_0_Height_0_When_ComputeArea_Then_0()
        {
            int       expected = 0;
            Rectangle input    = new Rectangle();

            input.Width  = 0;
            input.Height = 0;
            RectangleOperation operation = new RectangleOperation();

            operation.Target = input;
            int actual = operation.ComputeArea();

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 6
0
        public void Given_Rectangle_width_0_height_0_when_computerarea_then_25()
        {
            int       expected = 0;
            Rectangle input    = new Rectangle();

            input.width  = 0;
            input.height = 0;
            RectangleOperation operation = new RectangleOperation();

            operation.Target = input;
            int actual = operation.ComputerArea();

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            int w = (int)numericUpDown1.Value;
            int h = (int)numericUpDown2.Value;

            ClassLabrary.Rectangle width = new ClassLabrary.Rectangle()
            {
                width = w, height = h
            };
            RectangleOperation total = new RectangleOperation();

            total.Target = width;
            int Area = total.ComputerArea();

            label4.Text = Area.ToString();
        }
Ejemplo n.º 8
0
        private void ComputeButton_Click(object sender, EventArgs e)
        {
            int width  = Convert.ToInt32(width_NumericUpDown.Value);
            int height = Convert.ToInt32(height_NumericUpDown.Value);

            RectangleLibrary.Rectangle rect = new RectangleLibrary.Rectangle()
            {
                Width = width, Height = height
            };
            RectangleOperation operation = new RectangleOperation();

            operation.Target = rect;
            int area = operation.ComputeArea();

            resultLabel.Text = $"長方形的面積為 {area}";
        }
Ejemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            int width = 0;

            Int32.TryParse(numericUpDown1.Value.ToString(), out width);
            var height = (int)numericUpDown2.Value;

            RectangleLibrary.Rectangle rect = new RectangleLibrary.Rectangle()
            {
                Width = width, Height = height
            };
            RectangleOperation operation = new RectangleOperation();

            operation.Target = rect;
            int area = operation.ComputeArea();

            label3.Text = area.ToString();
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            int width  = 0;
            int height = 0;

            Console.WriteLine("請輸入長方形的寬");
            Int32.TryParse(Console.ReadLine(), out width);
            Console.WriteLine("請輸入長方形的高");
            Int32.TryParse(Console.ReadLine(), out height);
            Rectangle rect = new Rectangle()
            {
                Width = width, Height = height
            };
            RectangleOperation operation = new RectangleOperation();

            operation.Target = rect;
            int area = operation.ComputeArea();

            Console.WriteLine($"長方形的面積為{area}");

            Console.ReadLine();
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 根据指定的操作模式对矩形进行操作
 /// </summary>
 /// <param name="ro">指定的操作模式</param>
 public void RectangleOperating(RectangleOperation ro)
 {
     _DrawingBoard.RectangleOperating(ro);
 }
Ejemplo n.º 12
0
        /// <summary>根据指定的操作模式对矩形进行操作
        /// </summary>
        /// <param name="ro">指定的操作模式</param>
        public void RectangleOperating(RectangleOperation ro)
        {
            switch (ro)
            {
                #region case
            case RectangleOperation.AlignBottom:
                AlignBottom();
                break;

            case RectangleOperation.AlignCenter:
                AlignCenter();
                break;

            case RectangleOperation.AlignHeight:
                AlignHeight();
                break;

            case RectangleOperation.AlignLeft:
                AlignLeft();
                break;

            case RectangleOperation.AlignMiddle:
                AlignMiddle();
                break;

            case RectangleOperation.AlignRight:
                AlignRight();
                break;

            case RectangleOperation.AlignSame:
                AlignSame();
                break;

            case RectangleOperation.AlignTop:
                AlignTop();
                break;

            case RectangleOperation.AlignWidth:
                AlignWidth();
                break;

            case RectangleOperation.ArrowDown:
                ArrowDown();
                break;

            case RectangleOperation.ArrowIn:
                ArrowIn();
                break;

            case RectangleOperation.ArrowLeft:
                ArrowLeft();
                break;

            case RectangleOperation.ArrowOut:
                ArrowOut();
                break;

            case RectangleOperation.ArrowRight:
                ArrowRight();
                break;

            case RectangleOperation.ArrowUp:
                ArrowUp();
                break;
                #endregion
            }
        }