Exemple #1
0
        public void Execute_WhenFileIsNotFound_CreatesMessageForMissingFile()
        {
            var subject = new TokenSearch();

            subject.Files  = new[] { new TaskItem("notfound.txt") };
            subject.Tokens = Array.ConvertAll(DefaultTokens.Split(';'), token => new TaskItem(token));
            var engine = new BuildEngine();

            subject.BuildEngine = engine;

            var result = subject.Execute();

            Assert.True(result);
            Assert.Collection(engine.Logs,
                              x => Assert.Equal("Skipping 'notfound.txt' because it was not found.", ((BuildMessageEventArgs)x).Message));
        }
Exemple #2
0
        public void Execute_WhenFilesWithTokensAreIncluded_CreatesWarningsForTheTokens(string file, params string[] warnings)
        {
            var assemblyPath = Path.GetDirectoryName(typeof(TokenSearchTests).Assembly.Location);

            var subject  = new TokenSearch();
            var filePath = Path.Combine(assemblyPath, "TestCases", file);

            subject.Files  = new[] { new TaskItem(filePath) };
            subject.Tokens = Array.ConvertAll(DefaultTokens.Split(';'), token => new TaskItem(token));
            var engine = new BuildEngine();

            subject.BuildEngine = engine;

            var result = subject.Execute();

            Assert.True(result);
            Assert.Collection(engine.Logs,
                              warnings.Select(w => new Action <object>(x => Assert.Equal(w, ((BuildWarningEventArgs)x).Message))).ToArray());
        }
Exemple #3
0
        public void Execute_WhenFileIsBinary_CreatesMessageForSkippedFile()
        {
            var assemblyPath = Path.GetDirectoryName(typeof(TokenSearchTests).Assembly.Location);

            var subject  = new TokenSearch();
            var filePath = Path.Combine(assemblyPath, "TestCases", "test.gif");

            subject.Files  = new[] { new TaskItem(filePath) };
            subject.Tokens = Array.ConvertAll(DefaultTokens.Split(';'), token => new TaskItem(token));
            var engine = new BuildEngine();

            subject.BuildEngine = engine;

            var result = subject.Execute();

            Assert.True(result);
            Assert.Collection(engine.Logs,
                              x => Assert.Equal($"Skipping '{filePath}' because it appears to be a binary file.", ((BuildMessageEventArgs)x).Message));
        }