Exemple #1
0
        public void ReadParserConfig(byte chr, byte left, sbyte right, byte name, sbyte strand, sbyte summit, byte value, bool dropPeakIfInvalidValue, double defaultValue, PValueFormats pValueFormat)
        {
            // Arrange
            ParserConfig cols = new ParserConfig()
            {
                Chr                    = chr,
                Left                   = left,
                Right                  = right,
                Name                   = name,
                Strand                 = strand,
                Summit                 = summit,
                Value                  = value,
                DefaultValue           = defaultValue,
                PValueFormat           = pValueFormat,
                DropPeakIfInvalidValue = dropPeakIfInvalidValue,
            };
            var path = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "MSPCTests_" + new Random().NextDouble().ToString();

            using (StreamWriter w = new StreamWriter(path))
                w.WriteLine(JsonConvert.SerializeObject(cols));

            // Act
            ParserConfig parsedCols = ParserConfig.LoadFromJSON(path);

            File.Delete(path);

            // Assert
            Assert.True(parsedCols.Equals(cols));
        }
Exemple #2
0
        public void ReadMalformedJSON()
        {
            // Arrange
            var expected = new ParserConfig()
            {
                Chr = 123
            };
            var path = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "MSPCTests_" + new Random().NextDouble().ToString();

            using (StreamWriter w = new StreamWriter(path))
                w.WriteLine("{\"m\":7,\"l\":789,\"u\":-1,\"Chr\":123,\"L\":9,\"R\":2,\"d\":-1}");

            // Act
            var parsedCols = ParserConfig.LoadFromJSON(path);

            File.Delete(path);

            // Assert
            Assert.True(parsedCols.Equals(expected));
        }