Exemplo n.º 1
0
        public void RegisterDefaultInstancePrefersSupportedVSLowerVersionInstanceOverStandAlone()
        {
            var msBuildInstances = new[]
            {
                new MSBuildInstance(
                    "Test Instance",
                    TestIO.GetRandomTempFolderPath(),
                    Version.Parse("16.3.2.3"),
                    DiscoveryType.VisualStudioSetup
                    ).AddDotNetCoreToFakeInstance(),
                GetStandAloneMSBuildInstance()
            };

            var msbuildLocator = new MSFakeLocator(msBuildInstances);
            var logger         = LoggerFactory.CreateLogger(nameof(RegisterDefaultInstancePrefersSupportedVSLowerVersionInstanceOverStandAlone));

            // test
            msbuildLocator.RegisterDefaultInstance(logger, dotNetInfo: null);

            Assert.NotNull(msbuildLocator.RegisteredInstance);
            Assert.Same(msBuildInstances[0], msbuildLocator.RegisteredInstance);

            // clean up
            msbuildLocator.DeleteFakeInstancesFolders();
        }
        public void RegisterDefaultInstanceStillPrefersTheFirstInstance()
        {
            var msBuildInstances = new[]
            {
                new MSBuildInstance(
                    "Test Instance",
                    TestIO.GetRandomTempFolderPath(),
                    Version.Parse("16.1.2.3"),
                    DiscoveryType.VisualStudioSetup
                    ),
                GetStandAloneMSBuildInstance()
            };

            var msbuildLocator = new MSFakeLocator(msBuildInstances);
            var logger         = LoggerFactory.CreateLogger(nameof(RegisterDefaultInstanceStillPrefersTheFirstInstance));

            // test
            msbuildLocator.RegisterDefaultInstance(logger);

            Assert.NotNull(msbuildLocator.RegisteredInstance);
            Assert.Same(msBuildInstances[0], msbuildLocator.RegisteredInstance);

            // clean up
            msbuildLocator.DeleteFakeInstancesFolders();
        }
Exemplo n.º 3
0
        public void StandAloneIsPreferredOverUnsupportedVS(string vsVersion)
        {
            var msBuildInstances = new[]
            {
                new MSBuildInstance(
                    "Test Instance",
                    TestIO.GetRandomTempFolderPath(),
                    Version.Parse(vsVersion),
                    DiscoveryType.VisualStudioSetup
                    ).AddDotNetCoreToFakeInstance(),
                GetStandAloneMSBuildInstance()
            };

            var msbuildLocator = new MSFakeLocator(msBuildInstances);
            var logger         = LoggerFactory.CreateLogger(nameof(StandAloneIsPreferredOverUnsupportedVS));

            // test
            msbuildLocator.RegisterDefaultInstance(logger);

            Assert.NotNull(msbuildLocator.RegisteredInstance);
            Assert.Same(msBuildInstances[1], msbuildLocator.RegisteredInstance);

            // clean up
            msbuildLocator.DeleteFakeInstancesFolders();
        }
Exemplo n.º 4
0
        public void RegisterDefaultInstanceFindsTheBestInstanceAvailable()
        {
            var msBuildInstances = new[]
            {
                GetInvalidMsBuildInstance(),
                // Valid
                new MSBuildInstance(
                    "Test Instance",
                    TestIO.GetRandomTempFolderPath(),
                    Version.Parse("16.3.2.3"),
                    DiscoveryType.VisualStudioSetup
                    ).AddDotNetCoreToFakeInstance(),
                GetStandAloneMSBuildInstance()
            };

            var msbuildLocator = new MSFakeLocator(msBuildInstances);
            var logger         = LoggerFactory.CreateLogger(nameof(RegisterDefaultInstanceFindsTheBestInstanceAvailable));

            // test
            msbuildLocator.RegisterDefaultInstance(logger);

            Assert.NotNull(msbuildLocator.RegisteredInstance);
            Assert.Same(msBuildInstances[1], msbuildLocator.RegisteredInstance);

            // clean up
            msbuildLocator.DeleteFakeInstancesFolders();
        }
 public InterpreterTest()
 {
     this.symbolTable = new SymbolTable();
     this.io          = new TestIO(new List <string> {
         "3"
     });
     this.interpreter = getInterpreter(TestHelpers.sampleProgram);
 }
 public void readingStrValuesToVariablesShouldUpdateTheValue(string source, string readValue)
 {
     this.io = new TestIO(new List <string> {
         "Hello", "World"
     });
     this.interpreter = getInterpreter(source);
     this.interpreter.interpret();
     Assert.Equal(readValue, this.symbolTable.getString("x"));
 }
Exemplo n.º 7
0
 private static MSBuildInstance GetStandAloneMSBuildInstance()
 {
     return(new MSBuildInstance(
                "Stand Alone :(",
                TestIO.GetRandomTempFolderPath(),
                Version.Parse("16.4.0.0"),
                DiscoveryType.StandAlone
                ).AddDotNetCoreToFakeInstance());
 }
Exemplo n.º 8
0
 private static MSBuildInstance GetInvalidMsBuildInstance()
 {
     return(new MSBuildInstance(
                "Invalid Instance",
                TestIO.GetRandomTempFolderPath(),
                Version.Parse("15.0.4.2"),
                DiscoveryType.VisualStudioSetup
                ));
 }
Exemplo n.º 9
0
 private static MSBuildInstance GetStandAloneMSBuildInstance()
 {
     return(new MSBuildInstance(
                "Stand Alone :(",
                TestIO.GetRandomTempFolderPath(),
                Version.Parse("99.0.0.0"),
                DiscoveryType.StandAlone
                ));
 }
Exemplo n.º 10
0
 static void Main()
 {
     //var testCancellation = new TestCancellation();
     //testCancellation.TestCancellationToken();
     //testCancellation.TestCancelCallback();
     //testCancellation.TestCancelPrerequisites();
     TestIO test = new TestIO();
     test.TestInputFromPreviousOutputWithCache();
 }
 public void readingIntValuesToVariablesShouldUpdateTheValue(string source, int readValue)
 {
     this.io = new TestIO(new List <string> {
         "10"
     });
     this.interpreter = getInterpreter(source);
     this.interpreter.interpret();
     Assert.Equal(readValue, this.symbolTable.getInt("x"));
 }
Exemplo n.º 12
0
        static void Main()
        {
            //var testCancellation = new TestCancellation();
            //testCancellation.TestCancellationToken();
            //testCancellation.TestCancelCallback();
            //testCancellation.TestCancelPrerequisites();
            TestIO test = new TestIO();

            test.TestInputFromPreviousOutputWithCache();
        }
Exemplo n.º 13
0
            public void GivenValidDifficultLevelInString_ReturnDifficultLevelInNumber()
            {
                var input = "2";
                var io    = new TestIO();

                io.SetToBeRead(input);
                var actual   = GameSettings.GetDifficultLevel(io);
                var expected = 2;

                Assert.Equal(expected, actual);
            }
Exemplo n.º 14
0
    public void Test_BasicPlot_CanRender()
    {
        double[] xs  = ScottPlot.Generate.Consecutive(51);
        double[] ys1 = ScottPlot.Generate.Sin(51);
        double[] ys2 = ScottPlot.Generate.Cos(51);

        var plt = new ScottPlot.Plot();

        plt.AddScatter(xs, ys1);
        plt.AddScatter(xs, ys2);

        TestIO.SaveFig(plt);
    }
Exemplo n.º 15
0
            public void GivenInvalidDifficultLevelInString_ReturnInvalidInputMessage()
            {
                var invalidInput = "1";
                var validInput   = "2";
                var io           = new TestIO();

                io.SetToBeRead(invalidInput);
                io.SetToBeRead(validInput);

                GameSettings.GetDifficultLevel(io);
                var actual = io.HasText(Instruction.InvalidInputMessage);

                Assert.True(actual);
            }
        internal string CreateFakeSdkFolder(SemanticVersion version)
        {
            var tempFolderPath = TestIO.GetRandomTempFolderPath();

            if (version is null)
            {
                return(tempFolderPath);
            }

            var versionFilePath = Path.Combine(tempFolderPath, ".version");

            File.WriteAllText(versionFilePath, version.ToString());

            return(tempFolderPath);
        }
Exemplo n.º 17
0
        private List <string> GetProgramOutput(string[] lines, string[] inputs)
        {
            FileReader.ClearInput();
            IOHandler io = new TestIO(inputs);

            foreach (string line in lines)
            {
                FileReader.AddInputLine(line);
            }
            string    input = ConcatLines(lines);
            BlockNode ast   = p.Parse(input);
            Visitor   v     = new InterpreterVisitor(io);

            v.VisitProgram(ast);
            FileReader.ClearInput();
            return(io.GetOutput());
        }
Exemplo n.º 18
0
        public void RegisterDefaultInstanceFindsUserOverrideAvailableEvenWithOtherValidInstances()
        {
            var msBuildInstances = new[]
            {
                new MSBuildInstance(
                    "Valid Test Instance",
                    TestIO.GetRandomTempFolderPath(),
                    Version.Parse("16.3.2.1"),
                    DiscoveryType.VisualStudioSetup
                    ),
                GetInvalidMsBuildInstance(),

                // Valid + Dotnet Core
                new MSBuildInstance(
                    "Another Valid Test Instance",
                    TestIO.GetRandomTempFolderPath(),
                    Version.Parse("16.1.2.3"),
                    DiscoveryType.VisualStudioSetup
                    ).AddDotNetCoreToFakeInstance(),
                GetStandAloneMSBuildInstance(),

                // user override
                new MSBuildInstance(
                    "Manually Overridden",
                    TestIO.GetRandomTempFolderPath(),
                    Version.Parse("1.0.0"),
                    DiscoveryType.UserOverride
                    ).AddDotNetCoreToFakeInstance(),
            };

            var msbuildLocator = new MSFakeLocator(msBuildInstances);

            var logger = LoggerFactory.CreateLogger(
                nameof(RegisterDefaultInstanceFindsUserOverrideAvailableEvenWithOtherValidInstances)
                );

            // test
            msbuildLocator.RegisterDefaultInstance(logger);

            Assert.NotNull(msbuildLocator.RegisteredInstance);
            Assert.Same(msBuildInstances[4], msbuildLocator.RegisteredInstance);

            // clean up
            msbuildLocator.DeleteFakeInstancesFolders();
        }
Exemplo n.º 19
0
        public void Zone_Should_Load_Files_In_Given_Directory()
        {
            // TODO: replace the dependencies on Ad using Castle Windsor

            string ad = @"//Start Date
                2015-10-21 16:00
                // End Date
                2099-12-31 08:15
                // Rotation
                20
                // Html
                <p>blah";

            var io = new TestIO();
            var dir = new DummyDirectory("dir");
            dir.DummyFiles.Add("file1.html", ad);
            dir.DummyFiles.Add("file2.html", ad);
            io.DummyDirectories.Add("dir", dir);

            var sut = new Zone(io, "dir");

            Assert.AreEqual(2, sut.Ads.Count);
        }
Exemplo n.º 20
0
        public void RegisterDefaultInstanceFindsTheNewestInstanceAvailableEvenWithOtherValidInstances()
        {
            var msBuildInstances = new[]
            {
                new MSBuildInstance(
                    "Valid Test Instance",
                    TestIO.GetRandomTempFolderPath(),
                    Version.Parse("16.5.1.0"),
                    DiscoveryType.VisualStudioSetup
                    ).AddDotNetCoreToFakeInstance(),
                GetInvalidMsBuildInstance(),

                // same but newer minor version
                new MSBuildInstance(
                    "Another Valid Test Instance",
                    TestIO.GetRandomTempFolderPath(),
                    Version.Parse("16.6.1.0"),
                    DiscoveryType.VisualStudioSetup
                    ).AddDotNetCoreToFakeInstance(),
                GetStandAloneMSBuildInstance()
            };

            var msbuildLocator = new MSFakeLocator(msBuildInstances);

            var logger = LoggerFactory.CreateLogger(
                nameof(RegisterDefaultInstanceFindsTheBestInstanceAvailableEvenWithOtherValidInstances)
                );

            // test
            msbuildLocator.RegisterDefaultInstance(logger);

            Assert.NotNull(msbuildLocator.RegisteredInstance);
            Assert.Same(msBuildInstances[2], msbuildLocator.RegisteredInstance);

            // clean up
            msbuildLocator.DeleteFakeInstancesFolders();
        }
Exemplo n.º 21
0
 public ParserTest()
 {
     this.io     = new TestIO();
     this.parser = getParser(sampleProgram);
 }
Exemplo n.º 22
0
 public ParserExceptionTest()
 {
     this.parser = TestHelpers.getParser("");
     this.io     = new TestIO();
 }