Exemple #1
0
            public void ShouldReturnTrueOnReferenceLine(IFileParser parser, ReferenceLineProcessor processor)
            {
                // Arrange
                const string Line = @"#r ""MyDll.dll""";

                // Act
                var result = processor.ProcessLine(parser, new FileParserContext(), Line, true);

                // Assert
                result.ShouldBeTrue();
            }
Exemple #2
0
            public void ShouldReturnFalseOtherwise(IFileParser parser, ReferenceLineProcessor processor)
            {
                // Arrange
                const string Line = @"var x = new Test();";

                // Act
                var result = processor.ProcessLine(parser, new FileParserContext(), Line, true);

                // Assert
                result.ShouldBeFalse();
            }
            public void ShouldReturnFalseOtherwise(IFileParser parser, ReferenceLineProcessor processor)
            {
                // Arrange
                const string Line = @"var x = new Test();";

                // Act
                var result = processor.ProcessLine(parser, new FileParserContext(), Line, true);

                // Assert
                result.ShouldBeFalse();
            }
            public void ShouldReturnTrueOnReferenceLine(IFileParser parser, ReferenceLineProcessor processor)
            {
                // Arrange
                const string Line = @"#r ""MyDll.dll""";

                // Act
                var result = processor.ProcessLine(parser, new FileParserContext(), Line, true);

                // Assert
                result.ShouldBeTrue();
            }
Exemple #5
0
            public void ShouldExpandEnvironmentVariables(
                [Frozen] Mock <IFileSystem> fileSystem,
                ReferenceLineProcessor processor,
                IFileParser parser)
            {
                // Arrange
                var context = new FileParserContext();
                var line    = string.Format("#r %{0}%", EnvVarKey);

                // Act
                processor.ProcessLine(parser, context, line, true);

                // Assert
                fileSystem.Verify(x => x.GetFullPath(EnvVarValue));
            }
            public void ShouldExpandEnvironmentVariables(
                [Frozen] Mock<IFileSystem> fileSystem,
                ReferenceLineProcessor processor,
                IFileParser parser)
            {
                // Arrange
                var context = new FileParserContext();
                var line = string.Format("#r %{0}%", EnvVarKey);

                // Act
                processor.ProcessLine(parser, context, line, true);

                // Assert
                fileSystem.Verify(x => x.GetFullPath(EnvVarValue));
            }
            public void ShouldThrowExceptionIfAfterCode(
                [Frozen] Mock <IFileSystem> fileSystem,
                ReferenceLineProcessor processor,
                IFileParser parser)
            {
                // Arrange
                var context = new FileParserContext();

                const string RelativePath = "..\\script.csx";
                const string Line         = @"#r " + RelativePath;
                const string FullPath     = "C:\\script.csx";

                fileSystem.Setup(x => x.GetFullPath(RelativePath)).Returns(FullPath);

                // Act / Assert
                Xunit.Assert.Throws <InvalidDirectiveUseException>(() => processor.ProcessLine(parser, context, Line, false));
            }
            public void ShouldThrowExceptionIfAfterCode(
                [Frozen] Mock<IFileSystem> fileSystem,
                ReferenceLineProcessor processor,
                IFileParser parser)
            {
                // Arrange
                var context = new FileParserContext();

                const string RelativePath = "..\\script.csx";
                const string Line = @"#r " + RelativePath;
                const string FullPath = "C:\\script.csx";

                fileSystem.Setup(x => x.GetFullPath(RelativePath)).Returns(FullPath);
                
                // Act / Assert
                Assert.Throws(typeof(InvalidDirectiveUseException), () => processor.ProcessLine(parser, context, Line, false));
            }
Exemple #9
0
            public void ShouldAddReferenceToContext(
                [Frozen] Mock <IFileSystem> fileSystem,
                ReferenceLineProcessor processor,
                IFileParser parser)
            {
                // Arrange
                var context = new FileParserContext();

                const string RelativePath = "..\\Assembly.dll";
                const string Line         = @"#r " + RelativePath;
                const string FullPath     = "C:\\Assembly.dll";

                fileSystem.Setup(x => x.GetFullPath(RelativePath)).Returns(FullPath);

                // Act
                processor.ProcessLine(parser, context, Line, true);

                // Assert
                context.References.Count.ShouldEqual(1);
            }
            public void ShouldAddReferenceToContext(
                [Frozen] Mock<IFileSystem> fileSystem,
                ReferenceLineProcessor processor,
                IFileParser parser)
            {
                // Arrange
                var context = new FileParserContext();

                const string RelativePath = "..\\Assembly.dll";
                const string Line = @"#r " + RelativePath;
                const string FullPath = "C:\\Assembly.dll";

                fileSystem.Setup(x => x.GetFullPath(RelativePath)).Returns(FullPath);

                // Act
                processor.ProcessLine(parser, context, Line, true);

                // Assert
                context.References.Count.ShouldEqual(1);
            }
Exemple #11
0
            public void ShouldReturnTrueButNotAddReferenceIfAfterCode(
                [Frozen] Mock <IFileSystem> fileSystem,
                ReferenceLineProcessor processor,
                IFileParser parser)
            {
                // Arrange
                var context = new FileParserContext();

                const string RelativePath = "..\\script.csx";
                const string Line         = @"#r " + RelativePath;
                const string FullPath     = "C:\\script.csx";

                fileSystem.Setup(x => x.GetFullPath(RelativePath)).Returns(FullPath);

                // Act
                var result = processor.ProcessLine(parser, context, Line, false);

                // Assert
                result.ShouldBeTrue();
                context.References.Count.ShouldEqual(0);
            }
            public void ShouldAddReferenceByNameFromGACIfLocalFileDoesntExist(
                [Frozen] Mock<IFileSystem> fileSystem,
                ReferenceLineProcessor processor,
                IFileParser parser)
            {
                // Arrange
                var context = new FileParserContext();

                var name = "script.csx";
                var line = @"#r " + name;
                var fullPath = "C:\\script.csx";

                fileSystem.Setup(x => x.GetFullPath(name)).Returns(fullPath);
                fileSystem.Setup(x => x.FileExists(fullPath)).Returns(false);

                // Act
                var result = processor.ProcessLine(parser, context, line, true);

                // Assert
                context.References.Count(x => x == name).ShouldEqual(1);
            }
            public void ShouldAddReferenceByNameFromGACIfLocalFileDoesntExist(
                [Frozen] Mock <IFileSystem> fileSystem,
                ReferenceLineProcessor processor,
                IFileParser parser)
            {
                // Arrange
                var context = new FileParserContext();

                var name     = "script.csx";
                var line     = @"#r " + name;
                var fullPath = "C:\\script.csx";

                fileSystem.Setup(x => x.GetFullPath(name)).Returns(fullPath);
                fileSystem.Setup(x => x.FileExists(fullPath)).Returns(false);

                // Act
                processor.ProcessLine(parser, context, line, true);

                // Assert
                context.References.Count(x => x == name).ShouldEqual(1);
            }
            public void ShouldReturnTrueButNotAddReferenceIfAfterCode(
                [Frozen] Mock<IFileSystem> fileSystem,
                ReferenceLineProcessor processor,
                IFileParser parser)
            {
                // Arrange
                var context = new FileParserContext();

                const string RelativePath = "..\\script.csx";
                const string Line = @"#r " + RelativePath;
                const string FullPath = "C:\\script.csx";

                fileSystem.Setup(x => x.GetFullPath(RelativePath)).Returns(FullPath);

                // Act
                var result = processor.ProcessLine(parser, context, Line, false);

                // Assert
                result.ShouldBeTrue();
                context.References.Count.ShouldEqual(0);
            }