added first unit test
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							@ -41,6 +41,7 @@
 | 
			
		||||
            this.button4 = new System.Windows.Forms.Button();
 | 
			
		||||
            this.label4 = new System.Windows.Forms.Label();
 | 
			
		||||
            this.label5 = new System.Windows.Forms.Label();
 | 
			
		||||
            this.button5 = new System.Windows.Forms.Button();
 | 
			
		||||
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
 | 
			
		||||
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
 | 
			
		||||
            ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
 | 
			
		||||
@ -173,6 +174,16 @@
 | 
			
		||||
            this.label5.TabIndex = 12;
 | 
			
		||||
            this.label5.Text = "label5";
 | 
			
		||||
            // 
 | 
			
		||||
            // button5
 | 
			
		||||
            // 
 | 
			
		||||
            this.button5.Location = new System.Drawing.Point(68, 396);
 | 
			
		||||
            this.button5.Name = "button5";
 | 
			
		||||
            this.button5.Size = new System.Drawing.Size(75, 23);
 | 
			
		||||
            this.button5.TabIndex = 13;
 | 
			
		||||
            this.button5.Text = "store";
 | 
			
		||||
            this.button5.UseVisualStyleBackColor = true;
 | 
			
		||||
            this.button5.Click += new System.EventHandler(this.Button5_Click);
 | 
			
		||||
            // 
 | 
			
		||||
            // Form1
 | 
			
		||||
            // 
 | 
			
		||||
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
 | 
			
		||||
@ -180,6 +191,7 @@
 | 
			
		||||
            this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
 | 
			
		||||
            this.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
 | 
			
		||||
            this.ClientSize = new System.Drawing.Size(800, 450);
 | 
			
		||||
            this.Controls.Add(this.button5);
 | 
			
		||||
            this.Controls.Add(this.label5);
 | 
			
		||||
            this.Controls.Add(this.label4);
 | 
			
		||||
            this.Controls.Add(this.button4);
 | 
			
		||||
@ -221,6 +233,7 @@
 | 
			
		||||
        private System.Windows.Forms.Button button4;
 | 
			
		||||
        private System.Windows.Forms.Label label4;
 | 
			
		||||
        private System.Windows.Forms.Label label5;
 | 
			
		||||
        private System.Windows.Forms.Button button5;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -76,12 +76,10 @@ namespace WindowsFormsApp01
 | 
			
		||||
            var f = new CalcEventArgs(res);
 | 
			
		||||
            //trigger handler
 | 
			
		||||
 | 
			
		||||
           // if (CalcFinished != null)
 | 
			
		||||
          //  {
 | 
			
		||||
                CalcFinished(f);
 | 
			
		||||
           // }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            // if (CalcFinished != null)
 | 
			
		||||
            //  {
 | 
			
		||||
            CalcFinished(f);
 | 
			
		||||
            // }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -91,11 +89,46 @@ namespace WindowsFormsApp01
 | 
			
		||||
 | 
			
		||||
            Pen _pen = new ClassLibrary01.Class1().getPen();
 | 
			
		||||
 | 
			
		||||
            using (var p = _pen)
 | 
			
		||||
            {
 | 
			
		||||
                draw(graphics);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Brush aBrush = (Brush) Brushes.Red;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            for (int i = 10; i < (502); i++)
 | 
			
		||||
            {
 | 
			
		||||
                int y = (int) (246 - (((Math.Log(i) * 10) - 23) * _scale));
 | 
			
		||||
 | 
			
		||||
                graphics.FillRectangle(aBrush, i, y, 2, 2);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void storeToFile()
 | 
			
		||||
        {
 | 
			
		||||
            Bitmap bmp = new Bitmap(100, 200);
 | 
			
		||||
 | 
			
		||||
            var graphics = Graphics.FromImage(bmp);
 | 
			
		||||
 | 
			
		||||
            draw(graphics);
 | 
			
		||||
 | 
			
		||||
            bmp.Save(@"C:\Temp\AI.png");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void draw(Graphics graphics)
 | 
			
		||||
        {
 | 
			
		||||
            Pen _pen = new ClassLibrary01.Class1().getPen();
 | 
			
		||||
 | 
			
		||||
            graphics.Clear(Color.Aqua);
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            using (var p = _pen)
 | 
			
		||||
            {
 | 
			
		||||
                //y axis
 | 
			
		||||
                graphics.DrawLine(p, 10, 10, 10, 246);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                //x axis
 | 
			
		||||
                graphics.DrawLine(p, 10, 246, 502, 246);
 | 
			
		||||
 | 
			
		||||
@ -107,19 +140,6 @@ namespace WindowsFormsApp01
 | 
			
		||||
                graphics.DrawLine(p, 498, 241, 502, 246);
 | 
			
		||||
                graphics.DrawLine(p, 498, 251, 502, 246);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Brush aBrush = (Brush) Brushes.Red;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            for (int i = 10; i < (502); i++)
 | 
			
		||||
            {
 | 
			
		||||
                int y = (int) (246 - (((Math.Log(i) * 10) - 23) * _scale));
 | 
			
		||||
 | 
			
		||||
                graphics.FillRectangle(aBrush, i, y, 2, 2);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            //graphics.DrawEllipse(new Pen(Color.Black), 70, 70, 30, 10);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void Form1_Load(object sender, EventArgs e)
 | 
			
		||||
@ -204,11 +224,7 @@ namespace WindowsFormsApp01
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                label4.Text = "Fehler";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -216,6 +232,11 @@ namespace WindowsFormsApp01
 | 
			
		||||
        {
 | 
			
		||||
            label4.Text = e.Result.ToString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void Button5_Click(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            storeToFile();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class CalcEventArgs
 | 
			
		||||
@ -236,9 +257,6 @@ namespace WindowsFormsApp01
 | 
			
		||||
        public static event CalcEventHandler CalcFinished;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
       
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public static void CalcIt()
 | 
			
		||||
        {
 | 
			
		||||
            int res = DateTime.Now.Second;
 | 
			
		||||
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user