|
| 1 | +using DotNetMcp; |
| 2 | +using FluentAssertions; |
| 3 | +using Xunit; |
| 4 | + |
| 5 | +namespace DotNetMcp.Tests; |
| 6 | + |
| 7 | +public class FrameworkHelperTests |
| 8 | +{ |
| 9 | + [Theory] |
| 10 | + [InlineData("net9.0", true)] |
| 11 | + [InlineData("net8.0", true)] |
| 12 | + [InlineData("net7.0", true)] |
| 13 | + [InlineData("netcoreapp3.1", true)] |
| 14 | + [InlineData("netstandard2.0", true)] |
| 15 | + [InlineData("netstandard2.1", true)] |
| 16 | + [InlineData("invalid", false)] |
| 17 | + [InlineData("", false)] |
| 18 | + public void IsValidFramework_ValidatesCorrectly(string tfm, bool expected) |
| 19 | + { |
| 20 | + // Act |
| 21 | + var result = FrameworkHelper.IsValidFramework(tfm); |
| 22 | + |
| 23 | + // Assert |
| 24 | + result.Should().Be(expected); |
| 25 | + } |
| 26 | + |
| 27 | + [Theory] |
| 28 | + [InlineData("net8.0", true)] |
| 29 | + [InlineData("net6.0", true)] |
| 30 | + [InlineData("netcoreapp3.1", true)] |
| 31 | + [InlineData("netcoreapp2.1", true)] |
| 32 | + [InlineData("net9.0", false)] |
| 33 | + [InlineData("net7.0", false)] |
| 34 | + [InlineData("net5.0", false)] |
| 35 | + public void IsLtsFramework_IdentifiesLtsCorrectly(string tfm, bool expected) |
| 36 | + { |
| 37 | + // Act |
| 38 | + var result = FrameworkHelper.IsLtsFramework(tfm); |
| 39 | + |
| 40 | + // Assert |
| 41 | + result.Should().Be(expected); |
| 42 | + } |
| 43 | + |
| 44 | + [Theory] |
| 45 | + [InlineData("net9.0", ".NET 9.0")] |
| 46 | + [InlineData("net8.0", ".NET 8.0 (LTS)")] |
| 47 | + [InlineData("net6.0", ".NET 6.0 (LTS)")] |
| 48 | + [InlineData("netcoreapp3.1", ".NET Core 3.1 (LTS)")] |
| 49 | + [InlineData("netstandard2.0", ".NET Standard 2.0")] |
| 50 | + public void GetFrameworkDescription_ReturnsCorrectDescription(string tfm, string expected) |
| 51 | + { |
| 52 | + // Act |
| 53 | + var result = FrameworkHelper.GetFrameworkDescription(tfm); |
| 54 | + |
| 55 | + // Assert |
| 56 | + result.Should().Be(expected); |
| 57 | + } |
| 58 | + |
| 59 | + [Fact] |
| 60 | + public void GetLatestRecommendedFramework_ReturnsNet90() |
| 61 | + { |
| 62 | + // Act |
| 63 | + var result = FrameworkHelper.GetLatestRecommendedFramework(); |
| 64 | + |
| 65 | + // Assert |
| 66 | + result.Should().Be("net9.0"); |
| 67 | + } |
| 68 | + |
| 69 | + [Fact] |
| 70 | + public void GetLatestLtsFramework_ReturnsNet80() |
| 71 | + { |
| 72 | + // Act |
| 73 | + var result = FrameworkHelper.GetLatestLtsFramework(); |
| 74 | + |
| 75 | + // Assert |
| 76 | + result.Should().Be("net8.0"); |
| 77 | + } |
| 78 | + |
| 79 | + [Theory] |
| 80 | + [InlineData("net9.0", true)] |
| 81 | + [InlineData("net8.0", true)] |
| 82 | + [InlineData("net5.0", true)] |
| 83 | + [InlineData("netcoreapp3.1", false)] |
| 84 | + [InlineData("netstandard2.0", false)] |
| 85 | + [InlineData("net48", false)] |
| 86 | + public void IsModernNet_ClassifiesCorrectly(string tfm, bool expected) |
| 87 | + { |
| 88 | + // Act |
| 89 | + var result = FrameworkHelper.IsModernNet(tfm); |
| 90 | + |
| 91 | + // Assert |
| 92 | + result.Should().Be(expected); |
| 93 | + } |
| 94 | + |
| 95 | + [Theory] |
| 96 | + [InlineData("netcoreapp3.1", true)] |
| 97 | + [InlineData("netcoreapp2.1", true)] |
| 98 | + [InlineData("net9.0", false)] |
| 99 | + [InlineData("netstandard2.0", false)] |
| 100 | + public void IsNetCore_ClassifiesCorrectly(string tfm, bool expected) |
| 101 | + { |
| 102 | + // Act |
| 103 | + var result = FrameworkHelper.IsNetCore(tfm); |
| 104 | + |
| 105 | + // Assert |
| 106 | + result.Should().Be(expected); |
| 107 | + } |
| 108 | + |
| 109 | + [Theory] |
| 110 | + [InlineData("net48", true)] |
| 111 | + [InlineData("net472", true)] |
| 112 | + [InlineData("net9.0", false)] |
| 113 | + [InlineData("netcoreapp3.1", false)] |
| 114 | + public void IsNetFramework_ClassifiesCorrectly(string tfm, bool expected) |
| 115 | + { |
| 116 | + // Act |
| 117 | + var result = FrameworkHelper.IsNetFramework(tfm); |
| 118 | + |
| 119 | + // Assert |
| 120 | + result.Should().Be(expected); |
| 121 | + } |
| 122 | + |
| 123 | + [Theory] |
| 124 | + [InlineData("netstandard2.1", true)] |
| 125 | + [InlineData("netstandard2.0", true)] |
| 126 | + [InlineData("net9.0", false)] |
| 127 | + [InlineData("netcoreapp3.1", false)] |
| 128 | + public void IsNetStandard_ClassifiesCorrectly(string tfm, bool expected) |
| 129 | + { |
| 130 | + // Act |
| 131 | + var result = FrameworkHelper.IsNetStandard(tfm); |
| 132 | + |
| 133 | + // Assert |
| 134 | + result.Should().Be(expected); |
| 135 | + } |
| 136 | + |
| 137 | + [Fact] |
| 138 | + public void GetSupportedModernFrameworks_ReturnsExpectedCount() |
| 139 | + { |
| 140 | + // Act |
| 141 | + var result = FrameworkHelper.GetSupportedModernFrameworks(); |
| 142 | + |
| 143 | + // Assert |
| 144 | + result.Count.Should().BeGreaterThanOrEqualTo(5); |
| 145 | + result.Should().Contain("net9.0"); |
| 146 | + result.Should().Contain("net8.0"); |
| 147 | + } |
| 148 | + |
| 149 | + [Fact] |
| 150 | + public void GetSupportedNetCoreFrameworks_ReturnsExpectedFrameworks() |
| 151 | + { |
| 152 | + // Act |
| 153 | + var result = FrameworkHelper.GetSupportedNetCoreFrameworks(); |
| 154 | + |
| 155 | + // Assert |
| 156 | + result.Should().Contain("netcoreapp3.1"); |
| 157 | + result.Should().Contain("netcoreapp2.1"); |
| 158 | + } |
| 159 | + |
| 160 | + [Fact] |
| 161 | + public void GetSupportedNetStandardFrameworks_ReturnsExpectedFrameworks() |
| 162 | + { |
| 163 | + // Act |
| 164 | + var result = FrameworkHelper.GetSupportedNetStandardFrameworks(); |
| 165 | + |
| 166 | + // Assert |
| 167 | + result.Should().Contain("netstandard2.1"); |
| 168 | + result.Should().Contain("netstandard2.0"); |
| 169 | + } |
| 170 | +} |
0 commit comments