Beispiel #1
0
        public void FileFuzzingInput()
        {
            FileFuzzingInput c = new FileFuzzingInput("d:\\bof\\vulnserver.fmut")
            {
            };

            string ret = Encoding.ASCII.GetString(c.GetStream());
        }
Beispiel #2
0
        public void FileFuzzingInput()
        {
            var value = new FileFuzzingInput("Samples//PatchSample.fpatch")
            {
                Description = "Test",
                Id          = Guid.NewGuid()
            };

            CollectionAssert.AreEqual(File.ReadAllBytes("Samples//PatchSample.fpatch"), value.GetStream());

            // Regular constructor

            value = new FileFuzzingInput()
            {
                FileName = value.FileName
            };

            CollectionAssert.AreEqual(File.ReadAllBytes("Samples//PatchSample.fpatch"), value.GetStream());

            // Cache it

            value.UseCache = true;

            CollectionAssert.AreEqual(File.ReadAllBytes("Samples//PatchSample.fpatch"), value.GetStream());

            // Serialize

            var json  = SerializationHelper.SerializeToJson(value, true);
            var copy  = SerializationHelper.DeserializeFromJson <FileFuzzingInput>(json);
            var copy2 = SerializationHelper.DeserializeFromJson <FuzzingInputBase>(json);

            Assert.IsTrue(copy.Equals(copy2));

            // Equals

            Assert.IsTrue(value.Equals(copy));
            Assert.IsTrue(value.Equals((object)copy));
            Assert.IsFalse(value.Equals(new object()));
            Assert.IsFalse(value.Equals((FuzzingInputBase) new RandomFuzzingInput()));
            Assert.AreEqual(value.GetHashCode(), copy.GetHashCode());

            value.Id = Guid.NewGuid();
            Assert.AreNotEqual(value.GetHashCode(), copy.GetHashCode());
        }