public void TryParseReturnsResolvedVersions_WhenInputIsFromFile() { // Arrange var newLine = Environment.NewLine; var versionsToBeInstalledFile = Path.Combine(_tempDirRootPath, "input.txt"); File.WriteAllText(versionsToBeInstalledFile, $"p1=2.1.3{newLine}p2=3.1.3{newLine}"); var p1 = new TestProgrammingPlatform( name: "p1", detectedVersion: "1.0.0", resolvedVersion: "2.1.3"); var p2 = new TestProgrammingPlatform( name: "p2", detectedVersion: "1.0.0", resolvedVersion: "3.1.3"); // Act var actual = PrepareEnvironmentCommand.TryValidateSuppliedPlatformsAndVersions( new[] { p1, p2 }, suppliedPlatformsAndVersions: null, suppliedPlatformsAndVersionsFile: versionsToBeInstalledFile, new TestConsole(), out var results); // Assert Assert.True(actual); Assert.NotNull(results); Assert.Equal(2, results.Count); Assert.Equal("p1", results[0].Platform); Assert.Equal("2.1.3", results[0].PlatformVersion); Assert.Equal("p2", results[1].Platform); Assert.Equal("3.1.3", results[1].PlatformVersion); }
public void TryParseReturns_DoesCaseInsensitiveComparisonOfPlatformName() { // Arrange var suppliedPlatformsAndVersions = "PlatForm1=3.2.2, PLATFORM2=3.1.2"; var p1 = new TestProgrammingPlatform( name: "platform1", resolvedVersion: "3.2.2"); var p2 = new TestProgrammingPlatform( name: "platform2", resolvedVersion: "3.1.2"); // Act var actual = PrepareEnvironmentCommand.TryValidateSuppliedPlatformsAndVersions( new[] { p1, p2 }, suppliedPlatformsAndVersions, suppliedPlatformsAndVersionsFile: null, new TestConsole(), out var results); // Assert Assert.True(actual); Assert.NotNull(results); Assert.Equal(2, results.Count); Assert.Equal("platform1", results[0].Platform); Assert.Equal("3.2.2", results[0].PlatformVersion); Assert.Equal("platform2", results[1].Platform); Assert.Equal("3.1.2", results[1].PlatformVersion); }
public void TryParseReturnsDefaultVersions_WhenNoVersionSetForMultiplePlatforms() { // Arrange var suppliedPlatformsAndVersions = "p1, p2"; var p1 = new TestProgrammingPlatform( name: "p1", resolvedVersion: "2.1.3"); var p2 = new TestProgrammingPlatform( name: "p2", resolvedVersion: "3.1.3"); // Act var actual = PrepareEnvironmentCommand.TryValidateSuppliedPlatformsAndVersions( new[] { p1, p2 }, suppliedPlatformsAndVersions, suppliedPlatformsAndVersionsFile: null, new TestConsole(), out var results); // Assert Assert.True(actual); Assert.NotNull(results); Assert.Equal(2, results.Count); Assert.Equal("p1", results[0].Platform); Assert.Equal("2.1.3", results[0].PlatformVersion); Assert.Equal("p2", results[1].Platform); Assert.Equal("3.1.3", results[1].PlatformVersion); }
public void TryParseReturns_ReturnsFalseWhenPlatformNameIsNotValidAndInputIsFromFile() { // Arrange var newLine = Environment.NewLine; var versionsToBeInstalledFile = Path.Combine(_tempDirRootPath, "input.txt"); File.WriteAllText( versionsToBeInstalledFile, $"foo=3.2.2{newLine}p1=3.1.2"); var p1 = new TestProgrammingPlatform( name: "p1", resolvedVersion: "2.1.3"); // Act var actual = PrepareEnvironmentCommand.TryValidateSuppliedPlatformsAndVersions( new[] { p1 }, suppliedPlatformsAndVersions: null, suppliedPlatformsAndVersionsFile: versionsToBeInstalledFile, new TestConsole(), GetContext(), out var results); // Assert Assert.False(actual); }
public void TryParseReturnsFalse_IfSuppliedFileDoesNotExist() { // Arrange var versionsToBeInstalledFile = Path.Combine(_tempDirRootPath, "doestNotExist.txt"); var p1 = new TestProgrammingPlatform( name: "p1", resolvedVersion: "2.1.3"); // Act var actual = PrepareEnvironmentCommand.TryValidateSuppliedPlatformsAndVersions( new[] { p1 }, suppliedPlatformsAndVersions: null, suppliedPlatformsAndVersionsFile: versionsToBeInstalledFile, new TestConsole(), out var results); // Assert Assert.False(actual); }
public void TryParseReturns_ReturnsFalseWhenPlatformNameIsNotValid() { // Arrange var suppliedPlatformsAndVersions = "foo=3.2.2, p1=3.1.2"; var p1 = new TestProgrammingPlatform( name: "p1", resolvedVersion: "2.1.3"); // Act var actual = PrepareEnvironmentCommand.TryValidateSuppliedPlatformsAndVersions( new[] { p1 }, suppliedPlatformsAndVersions, suppliedPlatformsAndVersionsFile: null, new TestConsole(), out var results); // Assert Assert.False(actual); }
public void TryParseReturnsFalseWhenNoInputsAreProvided() { // Arrange var p1 = new TestProgrammingPlatform( name: "p1", detectedVersion: "1.0.0", resolvedVersion: "2.1.3"); var p2 = new TestProgrammingPlatform( name: "p2", detectedVersion: "1.0.0", resolvedVersion: "3.1.3"); // Act var actual = PrepareEnvironmentCommand.TryValidateSuppliedPlatformsAndVersions( new[] { p1, p2 }, suppliedPlatformsAndVersions: null, suppliedPlatformsAndVersionsFile: null, new TestConsole(), out var results); // Assert Assert.False(actual); }