[13538] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Windows.Forms;
|
---|
| 4 | using DistributedGA.Core;
|
---|
[13524] | 5 | using DistributedGA.Core.Domain;
|
---|
| 6 | using DistributedGA.Core.Implementation;
|
---|
| 7 | using DistributedGA.Core.Interface;
|
---|
| 8 |
|
---|
[13538] | 9 | namespace DistributedGA.Test {
|
---|
| 10 | public partial class Form1 : Form {
|
---|
| 11 | public Form1() {
|
---|
| 12 | InitializeComponent();
|
---|
| 13 | }
|
---|
[13524] | 14 |
|
---|
[13538] | 15 | private void button1_Click(object sender, EventArgs e) {
|
---|
| 16 | IMessageService s = new WcfMessageService();
|
---|
| 17 | s.Init("");
|
---|
| 18 | }
|
---|
[13524] | 19 |
|
---|
[13538] | 20 | private void button2_Click(object sender, EventArgs e) {
|
---|
| 21 | IMessageSender c = new WcfMessageSender();
|
---|
| 22 | c.Init(null);
|
---|
| 23 | c.SendPopulation(null, null);
|
---|
| 24 | }
|
---|
[13524] | 25 |
|
---|
[13538] | 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.PublishMigrationInfo(pop1);
|
---|
| 39 | h1.PublishMigrationInfo(pop1);
|
---|
| 40 | var res1 = h1.GetMigrationInfo();
|
---|
| 41 | var res2 = h2.GetMigrationInfo();
|
---|
| 42 | h1.PublishMigrationInfo(pop1);
|
---|
| 43 | h1.PublishMigrationInfo(pop1);
|
---|
| 44 | var res3 = h1.GetMigrationInfo();
|
---|
| 45 | var res4 = h2.GetMigrationInfo();
|
---|
| 46 | h1.PublishMigrationInfo(pop1);
|
---|
| 47 | h1.PublishMigrationInfo(pop1);
|
---|
| 48 | var res5 = h1.GetMigrationInfo();
|
---|
| 49 | var res6 = h2.GetMigrationInfo();
|
---|
| 50 | int i = 0;
|
---|
| 51 | }
|
---|
[13524] | 52 |
|
---|
[13538] | 53 | private void button4_Click(object sender, EventArgs e) {
|
---|
| 54 | var l = new WcfPeerListManager();
|
---|
| 55 | l.Init(CreatePeerInfo());
|
---|
| 56 | l.GetPeerList();
|
---|
| 57 | }
|
---|
[13524] | 58 |
|
---|
[13538] | 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 | }
|
---|
[13524] | 78 |
|
---|
[13538] | 79 | private PeerInfo CreatePeerInfo() {
|
---|
| 80 | return new PeerInfo() { IpAddress = "192.168.0.4", Port = 3030 };
|
---|
| 81 | }
|
---|
[13524] | 82 |
|
---|
[13538] | 83 | private SolutionInfo[] CreatePopulation() {
|
---|
| 84 | SolutionInfo si1 = new SolutionInfo() {
|
---|
| 85 | IterationNumber = 1,
|
---|
| 86 | Quality = 3.5f,
|
---|
| 87 | Solution = new Solution() {
|
---|
[13524] | 88 | }
|
---|
[13538] | 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 };
|
---|
[13524] | 103 | }
|
---|
[13538] | 104 | }
|
---|
[13524] | 105 | }
|
---|