Ejemplo n.º 1
0
        public void PublicKeyExchangeCommandTest()
        {
            var ui = new TestUi();

            using (
                var manager = new Station(
                    ui,
                    SystemTestData.Key,
                    SystemTestData.Password,
                    SystemTestData.ManagerPort,
                    "CommandsTestPublicKeyExchangeCommandTestManagerVoters.sqlite",
                    "CommandsTestPublicKeyExchangeCommandTestManagerLog.sqlite"))
                using (
                    var receiver = new Station(
                        ui, SystemTestData.StationPort,
                        "CommandsTestPublicKeyExchangeCommandTestReceiverVoters.sqlite")) {
                    var cmd = new PublicKeyExchangeCommand(manager, receiver.Address);
                    Assert.That(cmd.Sender.Equals(manager.Address));
                    Assert.That(!receiver.Peers.ContainsKey(manager.Address));
                    Assert.Null(receiver.Manager);
                    cmd.Execute(receiver);
                    Assert.That(receiver.Peers.ContainsKey(manager.Address));
                    Assert.That(receiver.Manager.Equals(manager.Address));
                }

            File.Delete("CommandsTestPublicKeyExchangeCommandTestManagerVoters.sqlite");
            File.Delete("CommandsTestPublicKeyExchangeCommandTestManagerLog.sqlite");
            File.Delete("CommandsTestPublicKeyExchangeCommandTestReceiverVoters.sqlite");
        }
Ejemplo n.º 2
0
        public void PublicKeyExchangeCommandTest()
        {
            var ui = new TestUi();

            using (var manager = new Station(ui, "dataEncryption.key", "pw", 65432, "CommandsTestPublicKeyExchangeCommandTestManagerVoters.sqlite", "CommandsTestPublicKeyExchangeCommandTestManagerLog.sqlite"))
                using (var receiver = new Station(ui, 65433, "CommandsTestPublicKeyExchangeCommandTestReceiverVoters.sqlite")) {
                    var cmd = new PublicKeyExchangeCommand(manager);
                    Assert.That(cmd.Sender.Equals(manager.Address));
                    Assert.That(!receiver.Peers.ContainsKey(manager.Address));
                    Assert.That(receiver.Manager == null);
                    cmd.Execute(receiver);
                    Assert.That(receiver.Peers.ContainsKey(manager.Address));
                    Assert.That(receiver.Manager.Equals(manager.Address));
                }
            File.Delete("CommandsTestPublicKeyExchangeCommandTestManagerVoters.sqlite");
            File.Delete("CommandsTestPublicKeyExchangeCommandTestManagerLog.sqlite");
            File.Delete("CommandsTestPublicKeyExchangeCommandTestReceiverVoters.sqlite");
        }