//[TestMethod]
        public void RegisterInRails()
        {
            SourceCodeInfo sourceCode = new SourceCodeInfo(GitTests.RepoPath);

            sourceCode.AddCodeFile("ClassA.cs");
            sourceCode.AddCodeFile("ClassB.cs");
            sourceCode.AddCodeFile("Program.cs");

            CodeRegisterer codeRegisterer = new CodeRegisterer();

            codeRegisterer.SendCodeContentsToServer(sourceCode);
        }
Ejemplo n.º 2
0
        public SourceCodeInfo GetSourceCodeInfo(string rootDir, string proName)
        {
            log.Debug(new { rootDir, proName });

            var sourceCodeInfo = new SourceCodeInfo(rootDir);

            var fullProjPath = Path.Combine(rootDir, proName);

            List <string> csFiles = new List <string>()
            {
            };

            try
            {
                log.Debug("Attempting to analyze CSPROJ and fetch code files");
                csFiles = cSFilesLister.GetCSCodeFiles(fullProjPath);
                log.InfoFormat("Found {0} CS Code files in this project", csFiles.Count);
                log.Debug(csFiles.ToArray());
            }
            catch (Exception e)
            {
                log.Error("Error in analyzing CSPROJ", e);
            }

            foreach (var item in csFiles)
            {
                sourceCodeInfo.AddCodeFile(item);
            }

            return(sourceCodeInfo);
        }
        public void TestRegesteringProject()
        {
            SourceCodeInfo sourceCode = new SourceCodeInfo(GitTests.RepoPath);

            sourceCode.AddCodeFile("ClassA.cs");

            var          mock = new Mock <IMessageDispatcher>();
            RedisMessage msg  = new RedisMessage("", "");

            mock.Setup(x => x.DispatchMessage(It.IsAny <RedisMessage>())).Callback((RedisMessage pmsg) => msg = pmsg);
            var codeHooks = new CodeHooks(mock.Object);

            CodeRegisterer codeRegisterer = new CodeRegisterer(codeHooks);

            codeRegisterer.SendCodeContentsToServer(sourceCode);


            mock.Verify(x => x.DispatchMessage(It.IsAny <RedisMessage>()), Times.AtLeast(1));

            Assert.IsTrue(msg.GetKey().Contains("CODE_RUN_EVENTS"));
            Assert.IsTrue(msg.GetMessage().Contains("ADD_SOURCE_FILE"));
            Assert.IsTrue(msg.GetMessage().Contains("ClassA.cs"));
            Assert.IsTrue(msg.GetMessage().Contains("MethodA_1"));
        }