public void RequestBallotCommandsTest()
        {
            var ui      = (TestUi)Manager.UI;
            var vn      = new VoterNumber(250000);
            var cpr     = new CPR(2312881234);
            var cmd     = new RequestBallotCommand(Station.Address, vn, cpr);
            var pswdcmd = new RequestBallotCPROnlyCommand(Station.Address, cpr, "yo boii");
            var data    = new List <EncryptedVoterData> {
                new EncryptedVoterData(new CipherText(Station.Crypto.AsymmetricEncrypt(Bytes.From(vn.Value), Station.Crypto.VoterDataEncryptionKey)), new CipherText(Station.Crypto.AsymmetricEncrypt(Bytes.From(cpr.Value), Station.Crypto.VoterDataEncryptionKey)), new CipherText(Station.Crypto.AsymmetricEncrypt(Bytes.From(cpr.Value + (uint)BallotStatus.NotReceived), Station.Crypto.VoterDataEncryptionKey)))
            };

            Manager.Database.Import(data);
            Station.Database.Import(data);
            Station.MasterPassword = Manager.MasterPassword;
            Manager.BallotReceived(vn, cpr);
            cmd.Execute(Manager);
            Assert.That(!ui.HandOutBallot);
            pswdcmd.Execute(Manager);
            Assert.That(!ui.HandOutBallot);

            Manager.RevokeBallot(vn, cpr);

            cmd     = new RequestBallotCommand(Manager.Address, vn, cpr);
            pswdcmd = new RequestBallotCPROnlyCommand(Manager.Address, cpr, "yo boii");
            cmd.Execute(Manager);
            Assert.That(ui.HandOutBallot);
            Manager.RevokeBallot(vn, cpr);
            pswdcmd.Execute(Manager);
            Assert.That(ui.HandOutBallot);
        }
        public void ManagerRequirementCheckTest()
        {
            var start = new StartElectionCommand(NewPeer.Address);
            var end   = new EndElectionCommand(NewPeer.Address);

            Assert.That(!((TestUi)Station.UI).OngoingElection);
            start.Execute(Station);
            Assert.That(!((TestUi)Station.UI).OngoingElection);
            Station.StartElection();
            Assert.That(Station.ElectionInProgress);
            end.Execute(Station);
            Assert.That(Station.ElectionInProgress);

            var vn            = new VoterNumber(5);
            var cpr           = new CPR(5);
            var req           = new RequestBallotCommand(NewPeer.Address, vn, cpr);
            var reqCPROnly    = new RequestBallotCPROnlyCommand(NewPeer.Address, cpr, "sup homey");
            var revoke        = new RevokeBallotCommand(NewPeer.Address, vn, cpr);
            var revokeCPROnly = new RevokeBallotCPROnlyCommand(NewPeer.Address, cpr, "sup homey");

            req.Execute(Station);
            reqCPROnly.Execute(Station);
            revoke.Execute(Station);
            revokeCPROnly.Execute(Station);
            Assert.That(Station.Database[vn, cpr] == BallotStatus.Unavailable);

            NewPeer.Crypto.VoterDataEncryptionKey = Manager.Crypto.VoterDataEncryptionKey;
            var sync = new SyncCommand(NewPeer);

            sync.Execute(Station);

            var promoteManager = new PromoteNewManagerCommand(NewPeer.Address, NewPeer.Address);

            promoteManager.Execute(Station);
            Assert.That(!Station.Manager.Equals(NewPeer.Address));
        }