示例#1
0
        public void TestInvalidByteLoad()
        {
            var secret = new RingSecret();

            Assert.Throws <SecretException>(() => secret.Load((byte[])null, GameRegion.US));
            Assert.Throws <SecretException>(() => secret.Load(new byte[] { 0 }, GameRegion.US));
            Assert.Throws <InvalidChecksumException>(() => secret.Load("L~2:N @bB↑& hmRhh", GameRegion.US));
            Assert.Throws <ArgumentException>(() =>
            {
                secret.Load("H~2:@ ←2♦yq GB3●9", GameRegion.US);
            });
        }
示例#2
0
        public void LoadSecretFromString()
        {
            var secret = new RingSecret();

            secret.Load(desiredSecretString, GameRegion.US);
            Assert.AreEqual(DesiredSecret, secret);
        }
        public void LoadSecretFromString()
        {
            RingSecret secret = new RingSecret();

            secret.Load(DesiredSecretString);

            Assert.AreEqual(14129, secret.GameID);
            Assert.AreEqual(Rings.PowerRingL1 | Rings.DoubleEdgeRing | Rings.ProtectionRing, secret.Rings);
        }
        private void btnDone_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (GameInfo == null)
                {
                    GameInfo = new GameInfo()
                    {
                        Region = _region
                    }
                }
                ;
                var trimmedData = data.Take(currentPic.Clamp(0, _secretLength)).ToArray();

                switch (Mode)
                {
                case SecretType.Game:
                    GameSecret gs = new GameSecret();
                    gs.Load(trimmedData, _region);
                    gs.UpdateGameInfo(GameInfo);
                    break;

                case SecretType.Ring:
                    RingSecret rs = new RingSecret();
                    rs.Load(trimmedData, _region);
                    rs.UpdateGameInfo(GameInfo, chkAppendRings.IsChecked == true);
                    break;

                case SecretType.Memory:
                    MemorySecret ms = new MemorySecret();
                    ms.Load(trimmedData, _region);
                    // Now what?
                    break;
                }

                this.Close();
            }
            catch (SecretException ex)
            {
                MessageBox.Show(ex.Message, "Invalid Secret", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#5
0
        protected void OnButtonOkPressed(object sender, EventArgs e)
        {
            try
            {
                if (GameInfo == null)
                {
                    GameInfo = new GameInfo();
                }
                var trimmedData = data.Take(currentPic.Clamp(0, _secretLength)).ToArray();

                switch (Mode)
                {
                case SecretType.Game:
                    GameSecret gs = new GameSecret(_region);
                    gs.Load(trimmedData);
                    gs.UpdateGameInfo(GameInfo);
                    break;

                case SecretType.Ring:
                    RingSecret rs = new RingSecret(_region);
                    rs.Load(trimmedData);
                    rs.UpdateGameInfo(GameInfo, chkAppendRings.Active);
                    break;

                case SecretType.Memory:
                    MemorySecret ms = new MemorySecret(_region);
                    ms.Load(trimmedData);
                    // Now what?
                    break;
                }

                this.Respond(ResponseType.Ok);
            }
            catch (InvalidSecretException ex)
            {
                MessageBox.Show(ex.Message, "Invalid Secret", ButtonsType.Ok, MessageType.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", ButtonsType.Ok, MessageType.Error);
            }
        }
示例#6
0
 public void LoadSecretFromString()
 {
     RingSecret secret = new RingSecret();
     secret.Load(DesiredSecretString);
     Assert.AreEqual(DesiredSecret, secret);
 }
示例#7
0
 public void LoadSecretFromBytes()
 {
     RingSecret secret = new RingSecret();
     secret.Load(DesiredSecretBytes);
     Assert.AreEqual(DesiredSecret, secret);
 }
示例#8
0
 public void LoadFromGameInfo()
 {
     RingSecret secret = new RingSecret();
     secret.Load(GameInfoTest.DesiredInfo);
     Assert.AreEqual(DesiredSecret, secret);
 }