Ejemplo n.º 1
0
        public void LoadSecretFromString()
        {
            var secret = new RingSecret();

            secret.Load(desiredSecretString, GameRegion.US);
            Assert.AreEqual(DesiredSecret, secret);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public void TestNotifyPropChanged()
        {
            bool hit = false;
            var  g   = new RingSecret();

            g.PropertyChanged += (s, e) => { hit = true; };
            g.GameID           = 42;
            Assert.IsTrue(hit);
        }
Ejemplo n.º 4
0
        public void TestEquals()
        {
            RingSecret s2 = new RingSecret()
            {
                GameID = 14129,
                Rings = Rings.PowerRingL1 | Rings.DoubleEdgeRing | Rings.ProtectionRing
            };

            Assert.AreEqual(DesiredSecret, s2);
        }
Ejemplo n.º 5
0
        public void TestNotEquals()
        {
            RingSecret s2 = new RingSecret()
            {
                GameID = 14129,
                Rings = Rings.BlueJoyRing | Rings.BombproofRing | Rings.HundredthRing
            };

            Assert.AreNotEqual(DesiredSecret, s2);
        }
Ejemplo n.º 6
0
        public void TestToBytes()
        {
            RingSecret secret = new RingSecret()
            {
                GameID = 14129,
                Rings  = Rings.PowerRingL1 | Rings.DoubleEdgeRing | Rings.ProtectionRing
            };

            Assert.AreEqual(DesiredSecretBytes, secret.ToBytes());
        }
Ejemplo n.º 7
0
        public void TestEquals()
        {
            var s2 = new RingSecret()
            {
                Region = GameRegion.US,
                GameID = 14129,
                Rings  = Rings.PowerRingL1 | Rings.DoubleEdgeRing | Rings.ProtectionRing
            };

            Assert.AreEqual(DesiredSecret, s2);
        }
Ejemplo n.º 8
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);
            });
        }
Ejemplo n.º 9
0
        public void TestNotEquals()
        {
            var s2 = new RingSecret()
            {
                Region = GameRegion.US,
                GameID = 14129,
                Rings  = Rings.BlueJoyRing | Rings.BombproofRing | Rings.HundredthRing
            };

            Assert.AreNotEqual(DesiredSecret, s2);
            Assert.AreNotEqual(DesiredSecret, null);
            Assert.AreNotEqual(DesiredSecret, "");
        }
Ejemplo n.º 10
0
        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);
            }
        }
Ejemplo n.º 11
0
        public void TestHashCode()
        {
            var r1 = new RingSecret(1234, GameRegion.US, Rings.All);
            var r2 = new RingSecret(5632, GameRegion.JP, Rings.BlueRing);

            var r3 = new RingSecret(9876, GameRegion.US, Rings.All);
            var r4 = new RingSecret(1234, GameRegion.US, Rings.All);

            // Because using mutable objects as a key is an awesome idea...
            var dict = new Dictionary <RingSecret, bool>
            {
                { r1, true },
                { r2, true }
            };

            Assert.That(dict, !Contains.Key(r3));
            Assert.That(dict, Contains.Key(r4));
        }
Ejemplo n.º 12
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);
            }
        }
Ejemplo n.º 13
0
        public void UpdateGameInfo()
        {
            var info = new GameInfo()
            {
                Region = GameRegion.US,
                GameID = 14129,
                Rings  = Rings.PowerRingL1
            };

            // Mismatched region
            var s1 = new RingSecret()
            {
                Region = GameRegion.JP,
                GameID = 14129,
                Rings  = Rings.DoubleEdgeRing | Rings.ProtectionRing
            };

            // Mismatched game ID
            var s2 = new RingSecret()
            {
                Region = GameRegion.US,
                GameID = 1,
                Rings  = Rings.DoubleEdgeRing | Rings.ProtectionRing
            };

            var s3 = new RingSecret()
            {
                Region = GameRegion.US,
                GameID = 14129,
                Rings  = Rings.DoubleEdgeRing | Rings.ProtectionRing
            };

            GameSecretTest.DesiredSecret.UpdateGameInfo(info);

            Assert.Throws <SecretException>(() => s1.UpdateGameInfo(info, true));
            Assert.Throws <SecretException>(() => s2.UpdateGameInfo(info, true));
            Assert.DoesNotThrow(() => s3.UpdateGameInfo(info, true));
            Assert.AreEqual(GameInfoTest.DesiredInfo, info);
        }
Ejemplo n.º 14
0
 public void LoadSecretFromString()
 {
     RingSecret secret = new RingSecret();
     secret.Load(DesiredSecretString);
     Assert.AreEqual(DesiredSecret, secret);
 }
Ejemplo n.º 15
0
 public void LoadSecretFromBytes()
 {
     RingSecret secret = new RingSecret();
     secret.Load(DesiredSecretBytes);
     Assert.AreEqual(DesiredSecret, secret);
 }
Ejemplo n.º 16
0
 public void LoadFromGameInfo()
 {
     RingSecret secret = new RingSecret();
     secret.Load(GameInfoTest.DesiredInfo);
     Assert.AreEqual(DesiredSecret, secret);
 }
Ejemplo n.º 17
0
        public void LoadFromGameInfo()
        {
            var secret = new RingSecret(GameInfoTest.DesiredInfo);

            Assert.AreEqual(DesiredSecret, secret);
        }