Ejemplo n.º 1
0
        public List <string> SimpleTestCases(IEnumerable <IChangeableData> a, IEnumerable <IChangeableData> b)
        {
            List <string> detectedItems = new List <string>();

            DataAnalyzer analyzer = new DataAnalyzer();

            analyzer.DetectedDifferenceEvent += (o, e) => detectedItems.Add(e);
            analyzer.Analyze(a, b);
            return(detectedItems);
        }
Ejemplo n.º 2
0
        public void DntNotAnalyzeIfSomeOfInputParametersAreNull(IEnumerable <IChangeableData> a, IEnumerable <IChangeableData> b)
        {
            List <string> detectedItems = new List <string>();
            DataAnalyzer  analyzer      = new DataAnalyzer();

            analyzer.DetectedDifferenceEvent += (o, e) => detectedItems.Add(e);

            analyzer.Analyze(a, b);
            Assert.IsEmpty(detectedItems);
        }
        public void AnalyzeTest_ShouldReturnCorrectSumAndIndices(double expectedDouble, int[] maxIndices, int[] badIndices, string path)
        {
            var analyzer           = new DataAnalyzer(path);
            var expectedMaxSum     = (decimal)expectedDouble;
            var expectedMaxIndices = maxIndices.ToList();
            var expectedBadIndices = badIndices.ToList();

            analyzer.Analyze();
            var maxSumValueEqual = analyzer.MaxSum == expectedMaxSum;
            var actualMaxIndices = analyzer.MaxSumIndices;
            var actualBadIndices = analyzer.BadStringsIndices;
            var indicesEqual     = expectedMaxIndices.SequenceEqual(actualMaxIndices);
            var actual           = maxSumValueEqual && indicesEqual;

            Assert.IsTrue(actual);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 分析波形
 /// </summary>
 /// <param name="testData">测试波形</param>
 /// <param name="sampleDelay">测试数据前面的无效数据长度</param>
 /// <param name="dataSize">有效测试波形长度</param>
 public virtual void Analyze(double[] testData, uint sampleDelay = 0, uint dataSize = 0)
 {
     if (!IsAnalyzeParamSet)
     {
         throw new SeeSharpAudioException(SeeSharpAudioErrorCode.AnalyzeParamNotSet,
                                          i18n.GetStr("Runtime.AnalyzeBeforeSetParam"));
     }
     double[] validTestData = GetValidTestData(testData, ref dataSize, sampleDelay);
     try
     {
         RawAnalyzer.Analyze(validTestData, dataSize);
         DataSize   = dataSize;
         IsAnalyzed = true;
     }
     catch (Exception ex)
     {
         throw new SeeSharpAudioException(SeeSharpAudioErrorCode.RuntimeError,
                                          i18n.GetFStr("Runtime.RuntimeError", ex.Message), ex);
     }
 }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            var path = string.Empty;

            if (args.Length > 0)
            {
                path = args[0];
            }

            while (!FileValidate.Validate(path))
            {
                Console.WriteLine(Messages.PromtPath);
                path = Console.ReadLine();
            }

            var analyzer = new DataAnalyzer(path);

            analyzer.Analyze();
            analyzer.Report();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            string path;

            if (args.Length == 0)
            {
                Console.WriteLine("Please type a path to data file");
                path = Console.ReadLine();
            }
            else
            {
                path = args[0];
            }
            int pageSize = 20;
            var analyzer = new DataAnalyzer(path);
            var helper   = new DataHelper();

            helper.Subscribe(analyzer);
            analyzer.Analyze();
            helper.SerializeData(analyzer);
            var printer = new ConsolePrinter(pageSize, analyzer.ExecutionTime, analyzer.People, analyzer.CurrentLine);

            printer.Print();
        }