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

Last change on this file since 13553 was 13553, checked in by thasling, 5 years ago

changed a few method names and other refactoring

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