Пример #1
0
        public void CanParse_should_be_false_then_true()
        {
            var args = new CanParseArgs()
            {
                File     = "common\\gamerules\\test.txt",
                GameType = "Stellaris"
            };
            var parser = new BinaryParser(new CodeParser(new Logger()), null);

            parser.CanParse(args).Should().BeFalse();
            args.File = "common\\gfx\\test.png";
            parser.CanParse(args).Should().BeTrue();
        }
Пример #2
0
        public void MustCorrectlyDetectValidPrefixes()
        {
            var data = new byte[123];
            var pswd = new MemoryStream(Encoding.UTF8.GetBytes(BinaryBlock.Password).Concat(data).ToArray());
            var pwcc = new MemoryStream(Encoding.UTF8.GetBytes(BinaryBlock.PasswordConfigureClient).Concat(data).ToArray());
            var plnd = new MemoryStream(Encoding.UTF8.GetBytes(BinaryBlock.PlainData).Concat(data).ToArray());
            var pkhs = new MemoryStream(Encoding.UTF8.GetBytes(BinaryBlock.PublicKey).Concat(data).ToArray());
            var phsk = new MemoryStream(Encoding.UTF8.GetBytes(BinaryBlock.PublicKeySymmetric).Concat(data).ToArray());

            Assert.IsFalse(sut.CanParse(null));
            Assert.IsFalse(sut.CanParse(new MemoryStream()));
            Assert.IsFalse(sut.CanParse(new MemoryStream(data)));

            Assert.IsTrue(sut.CanParse(pswd));
            Assert.IsTrue(sut.CanParse(pwcc));
            Assert.IsTrue(sut.CanParse(plnd));
            Assert.IsTrue(sut.CanParse(pkhs));
            Assert.IsTrue(sut.CanParse(phsk));
        }