Ejemplo n.º 1
0
                public void ShouldSetTheExtensionAsEmpty()
                {
                    var detector = new ExtensionDetector();
                    var result = detector.Detect("./some/file/path/.gitignore");

                    Assert.Equal(null, result.Extension);
                }
Ejemplo n.º 2
0
                public void ShouldClassifyTheFileAsUnknown()
                {
                    var detector = new ExtensionDetector();
                    var result = detector.Detect("./some/file/path/.gitignore");

                    Assert.Equal(null, result.Language);
                    Assert.Equal(DetectionResult.Unknown, result);
                }
Ejemplo n.º 3
0
                public void ShouldReturnTheLanguageAndNumberOfLines(string filepath, string resourceName,
                    ProgrammingLanguage expectedLanguage, int expectedlines)
                {
                    var detector = new ExtensionDetector();
                    var assembly = Assembly.GetExecutingAssembly();

                    var names = Assembly.GetExecutingAssembly().GetManifestResourceNames();

                    using (var stream = assembly.GetManifestResourceStream($"Proggr.LangDetect.Tests.Fixtures.{resourceName}"))
                    using (var reader = new StreamReader(stream))
                    {
                        var contents = reader.ReadToEnd();
                        var result = detector.Detect(filepath, contents);

                        Assert.Equal(expectedLanguage, result.Language);
                        Assert.Equal(expectedlines, result.Lines);
                    }
                }