コード例 #1
0
        public void TestSubstDETMultipleDetectors()
        {
            String parameters = "-a [DET]";

            IResultNode top1   = MockRepository.GenerateStub <IResultNode>();
            IResultNode top2   = MockRepository.GenerateStub <IResultNode>();
            IResultNode child1 = MockRepository.GenerateStub <IResultNode>();

            top1.Stub(t => t.Children).Return(new IResultNode[] { child1 });
            child1.Stub(c => c.Children).Return(new IResultNode[0]);
            top2.Stub(t => t.Children).Return(new IResultNode[0]);
            _selection.Stub(s => s.Results).Return(new IResultNode[] { top1, top2 });

            ICodecDetector okDetector = MockRepository.GenerateStub <ICodecDetector>();

            okDetector.Stub(d => d.Name).Return("ok detector");
            IDetector notOkDetector = MockRepository.GenerateStub <IDetector>();

            notOkDetector.Stub(d => d.Name).Return("not ok detector");

            top1.Stub(t => t.Detectors).Return(new IDetector[] { okDetector });
            top2.Stub(t => t.Detectors).Return(new IDetector[] { notOkDetector });
            child1.Stub(t => t.Detectors).Return(new IDetector[] { okDetector });

            String subst = _checker.Substitute(parameters, _selection, _dataPacket, outputFilename);

            Assert.AreEqual(subst, "-a \"ok detector\"");
        }
コード例 #2
0
        public void TestSubstLISTO()
        {
            String parameters = "-z [LISTO]";

            IResultNode top1   = MockRepository.GenerateStub <IResultNode>();
            IResultNode child1 = MockRepository.GenerateStub <IResultNode>();
            IResultNode child2 = MockRepository.GenerateStub <IResultNode>();

            top1.Stub(t => t.Children).Return(new IResultNode[] { child1, child2 });
            child1.Stub(c => c.Children).Return(new IResultNode[0]);
            child2.Stub(c => c.Children).Return(new IResultNode[0]);

            IResultNode top2 = MockRepository.GenerateStub <IResultNode>();

            top2.Stub(t => t.Children).Return(new IResultNode[0]);

            _selection.Stub(s => s.Results).Return(new IResultNode[] { top1, top2 });

            top1.Stub(t => t.Length).Return(8);
            top1.Stub(t => t.StartOffset).Return(1);
            top2.Stub(t => t.Length).Return(17);
            top2.Stub(t => t.StartOffset).Return(2);
            child1.Stub(c => c.Length).Return(99);
            child1.Stub(c => c.StartOffset).Return(3);
            child2.Stub(c => c.Length).Return(66);
            child2.Stub(c => c.StartOffset).Return(4);

            String subst = _checker.Substitute(parameters, _selection, _dataPacket, outputFilename);

            Assert.AreEqual(subst, "-z 1 8 3 99 4 66 2 17");
        }
コード例 #3
0
        public void TestSubstSIZEH()
        {
            String      parameters = "-abc [SIZEH]";
            IResultNode child      = MockRepository.GenerateStub <IResultNode>();

            _selection.Stub(s => s.Results).Return(new IResultNode[] { child });
            child.Stub(c => c.Length).Return(666);

            String subst = _checker.Substitute(parameters, _selection, _dataPacket, outputFilename);

            Assert.AreEqual(subst, "-abc 666");
        }
コード例 #4
0
        public void TestWriteForensicLog()
        {
            String parameters = "-l [LOG]";

            IDetector[] detectors = new IDetector[0];

            _selection.Stub(s => s.Results).Return(new IResultNode[] { _resultNode });
            _resultNode.Stub(r => r.Detectors).Return(detectors);

            String subst = _checker.Substitute(parameters, _selection, _dataPacket, outputFilename);

            Assert.AreEqual(subst, "-l \"out file.csv\"");

            With.Mocks(_mockRepository).Expecting(delegate
            {
            }).Verify(delegate
            {
                _logger.Log(_dataPacket, detectors, outputFilename, Arg <FileStream> .Is.Anything, ForensicLogType.CopiedData);
            });
        }
コード例 #5
0
        public void TestSubstCount()
        {
            String parameters = "-l [COUNT]";

            IResultNode top1   = MockRepository.GenerateStub <IResultNode>();
            IResultNode child1 = MockRepository.GenerateStub <IResultNode>();
            IResultNode child2 = MockRepository.GenerateStub <IResultNode>();

            top1.Stub(t => t.Children).Return(new IResultNode[] { child1, child2 });
            child1.Stub(c => c.Children).Return(new IResultNode[0]);
            child2.Stub(c => c.Children).Return(new IResultNode[0]);
            IResultNode top2 = MockRepository.GenerateStub <IResultNode>();

            top2.Stub(t => t.Children).Return(new IResultNode[0]);

            _selection.Stub(s => s.Results).Return(new IResultNode[] { top1, top2 });

            String subst = _checker.Substitute(parameters, _selection, _dataPacket, outputFilename);

            Assert.AreEqual(subst, "-l 4");
        }