public Fixture()
 {
     HttpMessageHandler = new TestMessageHandler((message, token) =>
                                                 Task.FromResult(new HttpResponseMessage(HttpStatusCode.Created)));
     ObjectFileParser = new ObjectFileParser(Metrics,
                                             Options.Create(ObjectFileParserOptions),
                                             Substitute.For <ILogger <ObjectFileParser> >());
 }
Exemple #2
0
 public Symsorter(
     IOptions <SymsorterOptions> options,
     ObjectFileParser objectFileParser,
     ILogger <Symsorter> logger)
 {
     _options          = options.Value;
     _objectFileParser = objectFileParser;
     _logger           = logger;
     _jsonOptions      = new JsonSerializerOptions {
         WriteIndented = _options.WriteIndented
     };
 }
        public InMemorySymbolService(
            ObjectFileParser parser,
            IBatchFinalizer batchFinalizer,
            IOptions <SymbolServiceOptions> options,
            ILogger <InMemorySymbolService> logger)
        {
            _parser         = parser;
            _batchFinalizer = batchFinalizer;
            _options        = options.Value;
            _logger         = logger;

            _donePath       = Path.Combine(_options.BaseWorkingPath, "done");
            _processingPath = Path.Combine(_options.BaseWorkingPath, "processing");
            _conflictPath   = Path.Combine(_options.BaseWorkingPath, "conflict");
            Directory.CreateDirectory(_donePath);
            Directory.CreateDirectory(_processingPath);
            Directory.CreateDirectory(_conflictPath);
        }
Exemple #4
0
        public void SingleFileInTreeTest()
        {
            var file = new System.IO.FileInfo(Path.Combine(Path.GetTempPath(), "objects", "08", Path.GetRandomFileName()));

            if (!file.Directory.Exists)
            {
                file.Directory.Create();
            }

            File.WriteAllBytes(file.FullName, TestResources.singlefiletree);

            try
            {
                var result = ObjectFileParser.ParseFile(file);
                StringAssert.Contains(result.Body, "test.txt");
                StringAssert.Contains(result.Body, "d0f89fe97552ddd9cefcab879175436503bc9251");
            }
            finally
            {
                file.Delete();
            }
        }
Exemple #5
0
        /// <summary>
        /// Gets all of the CP names and their spawn paths from the specified object files.
        /// </summary>
        private void GetCPNamesAndPaths()
        {
            List <string> objectFiles = GetWorldChunkFilePaths(worldReqFilePath, worldModes[selectedModeMrq], new string[] { ".wld", ".lyr" });

            cpNamesAndPaths.Clear();
            rtb_OutputLog.Clear();

            foreach (string filePath in objectFiles)
            {
                List <ObjectChunk> objects = ObjectFileParser.GetObjectChunks(filePath);

                if (objects.Count > 0)
                {
                    // Add the CPs and their spawn paths to our Dictionary
                    foreach (ObjectChunk obj in objects)
                    {
                        // We're determining which objects are CPs by their name or if they have a SpawnPath param
                        if (obj.Parameters.ContainsKey("SpawnPath") || obj.ClassName.ToLower().Contains("controlzone"))
                        {
                            if (obj.Parameters.ContainsKey("SpawnPath"))
                            {
                                try
                                {
                                    cpNamesAndPaths.Add(obj.ObjectName, obj.Parameters["SpawnPath"]);
                                    rtb_OutputLog.Text += string.Format("{0}: {1}\n", obj.ObjectName, obj.Parameters["SpawnPath"]);
                                }
                                catch (ArgumentNullException ex)
                                {
                                    Trace.WriteLine(ex.Message);
                                    throw;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #6
0
        public void TestReadHeader()
        {
            var file = new System.IO.FileInfo(Path.Combine(Path.GetTempPath(), "objects", Path.GetRandomFileName()));

            if (!file.Directory.Exists)
            {
                file.Directory.Create();
            }
            File.WriteAllBytes(file.FullName, TestResources.singlefiletree);

            try
            {
                using (var stream = new Ionic.Zlib.ZlibStream(file.OpenRead(), Ionic.Zlib.CompressionMode.Decompress))
                {
                    ObjectHeader result = ObjectFileParser.ReadHeader(stream);
                    Assert.AreEqual(ObjectType.Tree, result.Type);
                    Assert.AreEqual(36, result.Size);
                }
            }
            finally
            {
                file.Delete();
            }
        }
Exemple #7
0
        public void DecodeTest()
        {
            var file = new System.IO.FileInfo(Path.Combine(Path.GetTempPath(), "objects", "08", Path.GetRandomFileName()));

            if (!file.Directory.Exists)
            {
                file.Directory.Create();
            }

            File.WriteAllBytes(file.FullName, TestResources.multifiletree);

            try
            {
                var result = ObjectFileParser.ParseFile(file);
                StringAssert.Contains(result.Body, "b39e4ee91acfd62f10b9b931daed0b0344a438b1");
                StringAssert.Contains(result.Body, "12c4cf90fa0e83fa111446ef4fedf2fc37e4ebc1");
                StringAssert.Contains(result.Body, "test.txt");
                StringAssert.Contains(result.Body, "nog een file.txt");
            }
            finally
            {
                file.Delete();
            }
        }
Exemple #8
0
        public void TestExtractReferenceFromHeadToCommit()
        {
            var result = ObjectFileParser.ExtractReferenceFromHead("987456");

            Assert.AreEqual("987456", result);
        }
Exemple #9
0
        public void TestExtractReferenceFromHeadToReference()
        {
            var result = ObjectFileParser.ExtractReferenceFromHead("ref: refs/heads/master");

            Assert.AreEqual("master", result);
        }