Free cookie consent management tool by TermsFeed Policy Generator

source: branches/thasling/DistributedGA/DistributedGA.Test/Form1.cs @ 13524

Last change on this file since 13524 was 13524, checked in by thasling, 8 years ago

Upload des Projekts letztendlich, trotz buggendes Clients...

File size: 4.0 KB
Line 
1using DistributedGA.Core;
2using DistributedGA.Core.Domain;
3using DistributedGA.Core.Implementation;
4using DistributedGA.Core.Interface;
5using System;
6using System.Collections.Generic;
7using System.ComponentModel;
8using System.Data;
9using System.Drawing;
10using System.Linq;
11using System.Text;
12using System.Threading;
13using System.Threading.Tasks;
14using System.Windows.Forms;
15
16namespace DistributedGA.Test
17{
18    public partial class Form1 : Form
19    {
20        public Form1()
21        {
22            InitializeComponent();
23        }
24
25        private void button1_Click(object sender, EventArgs e)
26        {
27            IMessageService s = new WcfMessageService();
28            s.Init("");
29        }
30
31        private void button2_Click(object sender, EventArgs e)
32        {
33            IMessageSender c = new WcfMessageSender();
34            c.Init(null);
35            c.SendPopulation(null, null);
36        }
37
38        private void button3_Click(object sender, EventArgs e)
39        {
40            IMessageHandler h1 = new PeerNetworkMessageHandler();
41            h1.Init();
42            IMessageHandler h2 = new PeerNetworkMessageHandler();
43            h2.Init();
44            IMessageHandler h3 = new PeerNetworkMessageHandler();
45            h3.Init();
46            IMessageHandler h4 = new PeerNetworkMessageHandler();
47            h4.Init();
48            IMessageHandler h5 = new PeerNetworkMessageHandler();
49            h5.Init();
50            var pop1 = CreatePopulation();
51            h1.PublishMigrationInfo(pop1);
52            h1.PublishMigrationInfo(pop1);
53            var res1 = h1.GetMigrationInfo();
54            var res2 = h2.GetMigrationInfo();
55            h1.PublishMigrationInfo(pop1);
56            h1.PublishMigrationInfo(pop1);
57            var res3 = h1.GetMigrationInfo();
58            var res4 = h2.GetMigrationInfo();
59            h1.PublishMigrationInfo(pop1);
60            h1.PublishMigrationInfo(pop1);
61            var res5 = h1.GetMigrationInfo();
62            var res6 = h2.GetMigrationInfo();
63            int i = 0;
64        }
65
66        private void button4_Click(object sender, EventArgs e)
67        {
68            var l = new WcfPeerListManager();
69            l.Init(CreatePeerInfo());
70            l.GetPeerList();
71        }     
72
73        private void button5_Click(object sender, EventArgs e)
74        {
75            Dictionary<string, int> d1 = new Dictionary<string, int>();
76            d1.Add("test", 5);
77            if(d1.ContainsKey("test"))
78            {
79                int i = 0;
80            }
81            else
82            {
83                int j = 0;
84            }
85            Dictionary<PeerInfo, int> d2 = new Dictionary<PeerInfo, int>();
86            PeerInfo p1 = CreatePeerInfo();
87            PeerInfo p2 = CreatePeerInfo();
88            d2.Add(p1, 5);
89            if (d2.ContainsKey(p1))
90            {
91                int i = 0;
92            }
93            if(d2.ContainsKey(p2))
94            {
95                int i = 0;
96            }
97        }
98
99        private PeerInfo CreatePeerInfo()
100        {
101            return new PeerInfo() { IpAddress = "192.168.0.4", Port = 3030 };
102        }
103
104        private  SolutionInfo[] CreatePopulation()
105        {
106            SolutionInfo si1 = new SolutionInfo()
107            {
108                IterationNumber = 1,
109                Quality = 3.5f,
110                Solution = new Solution()
111                {
112                }
113            };
114            SolutionInfo si2 = new SolutionInfo()
115            {
116                IterationNumber = 2,
117                Quality = 3.5f,
118                Solution = new Solution()
119                {
120                }
121            };
122            SolutionInfo si3 = new SolutionInfo()
123            {
124                IterationNumber = 3,
125                Quality = 3.5f,
126                Solution = new Solution()
127                {
128                }
129            };
130            return new SolutionInfo[] { si1, si2, si3 };
131        }
132    }
133}
Note: See TracBrowser for help on using the repository browser.