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(); }
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(); }
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")); }
private static MSBuildInstance GetStandAloneMSBuildInstance() { return(new MSBuildInstance( "Stand Alone :(", TestIO.GetRandomTempFolderPath(), Version.Parse("16.4.0.0"), DiscoveryType.StandAlone ).AddDotNetCoreToFakeInstance()); }
private static MSBuildInstance GetInvalidMsBuildInstance() { return(new MSBuildInstance( "Invalid Instance", TestIO.GetRandomTempFolderPath(), Version.Parse("15.0.4.2"), DiscoveryType.VisualStudioSetup )); }
private static MSBuildInstance GetStandAloneMSBuildInstance() { return(new MSBuildInstance( "Stand Alone :(", TestIO.GetRandomTempFolderPath(), Version.Parse("99.0.0.0"), DiscoveryType.StandAlone )); }
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")); }
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); }
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); }
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); }
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()); }
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(); }
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); }
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(); }
public ParserTest() { this.io = new TestIO(); this.parser = getParser(sampleProgram); }
public ParserExceptionTest() { this.parser = TestHelpers.getParser(""); this.io = new TestIO(); }