public void FrameworkCompatibility_NullInput() { // Arrange var target = GetToolsService(); FrameworkCompatibilityInput input = null; // Act var output = target.FrameworkCompatibility(input); // Assert Assert.Same(input, output.Input); Assert.Equal(InputStatus.Missing, output.InputStatus); Assert.False(output.IsProjectValid); Assert.False(output.IsPackageValid); Assert.Null(output.Project); Assert.Null(output.Package); Assert.False(output.IsCompatible); }
public void FrameworkCompatibility_MissingPackage() { // Arrange var target = GetToolsService(); var input = new FrameworkCompatibilityInput { Project = "net45", Package = null }; // Act var output = target.FrameworkCompatibility(input); // Assert Assert.Same(input, output.Input); Assert.Equal(InputStatus.Missing, output.InputStatus); Assert.True(output.IsProjectValid); Assert.False(output.IsPackageValid); Assert.Equal(GetFrameworkShortFolderName(input.Project), output.Project.ShortFolderName); Assert.Null(output.Package); Assert.False(output.IsCompatible); }
public void FrameworkCompatibility_InvalidProjectAndPackage() { // Arrange var target = GetToolsService(); var input = new FrameworkCompatibilityInput { Project = "portable-win8+net-cf", Package = "portable-net45+net-cf" }; // Act var output = target.FrameworkCompatibility(input); // Assert Assert.Same(input, output.Input); Assert.Equal(InputStatus.Invalid, output.InputStatus); Assert.False(output.IsProjectValid); Assert.False(output.IsPackageValid); Assert.Null(output.Project); Assert.Null(output.Package); Assert.False(output.IsCompatible); }
public async Task <IActionResult> FrameworkCompatibility([FromRoute] string nuGetVersion, [FromQuery] FrameworkCompatibilityInput input, bool swap, CancellationToken token) { var redirect = GetVersionRedirect(); if (redirect != null) { return(redirect); } var toolsService = await _toolsFactory.GetServiceAsync(nuGetVersion, token); if (toolsService == null) { return(NotFound()); } if (swap) { return(new RedirectToActionResult( nameof(FrameworkCompatibility), ControllerContext.ActionDescriptor.ControllerName, new { project = input.Package, package = input.Project }, permanent: false) { Permanent = false }); } var output = toolsService.FrameworkCompatibility(input); var versionedOutput = await GetSelectedVersionOutputAsync(toolsService, output, token); return(View(versionedOutput)); }
public FrameworkCompatibilityOutput FrameworkCompatibility(FrameworkCompatibilityInput input) { var output = new FrameworkCompatibilityOutput { InputStatus = InputStatus.Missing, Input = input }; if (input == null) { return(output); } var projectMissing = string.IsNullOrWhiteSpace(input.Project); var packageMissing = string.IsNullOrWhiteSpace(input.Package); var project = default(TFramework); if (!projectMissing) { try { project = _frameworkLogic.Parse(input.Project); output.Project = project; output.IsProjectValid = true; } catch (Exception) { output.IsProjectValid = false; } } var package = default(TFramework); if (!packageMissing) { try { package = _frameworkLogic.Parse(input.Package); output.Package = package; output.IsPackageValid = true; } catch (Exception) { output.IsPackageValid = false; } } if (!projectMissing && !packageMissing) { if (output.IsProjectValid && output.IsPackageValid) { output.InputStatus = InputStatus.Valid; output.IsCompatible = _frameworkLogic.IsCompatible(project, package); } else { output.InputStatus = InputStatus.Invalid; } } return(output); }