diff --git a/.github/workflows/first-workflow.yml b/.github/workflows/first-workflow.yml
new file mode 100644
index 00000000..dfda158b
--- /dev/null
+++ b/.github/workflows/first-workflow.yml
@@ -0,0 +1,26 @@
+name: My First Workflow
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ workflow_dispatch:
+
+jobs:
+ echo:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Step 1
+ run: echo "Step 1 complete"
+ - name: Step 2
+ run: echo "Step 2 complete"
+
+ cow:
+ name: Cowsays
+ runs-on: ubuntu-latest
+ steps:
+ - name: Ship it
+ uses: mscoutermarsh/cowsays-action@master
+ with:
+ text: 'Ready for prod–ship it!'
+ color: 'red'
\ No newline at end of file
diff --git a/src/Application/src/RazorPagesTestSample/Data/Message.cs b/src/Application/src/RazorPagesTestSample/Data/Message.cs
index ea99cbd6..59f24395 100644
--- a/src/Application/src/RazorPagesTestSample/Data/Message.cs
+++ b/src/Application/src/RazorPagesTestSample/Data/Message.cs
@@ -9,7 +9,7 @@ public class Message
[Required]
[DataType(DataType.Text)]
- [StringLength(200, ErrorMessage = "There's a 200 character limit on messages. Please shorten your message.")]
+ [StringLength(250, ErrorMessage = "There's a 250 character limit on messages. Please shorten your message.")]
public string Text { get; set; }
}
#endregion
diff --git a/src/Application/src/RazorPagesTestSample/Properties/launchSettings.json b/src/Application/src/RazorPagesTestSample/Properties/launchSettings.json
new file mode 100644
index 00000000..e428766f
--- /dev/null
+++ b/src/Application/src/RazorPagesTestSample/Properties/launchSettings.json
@@ -0,0 +1,12 @@
+{
+ "profiles": {
+ "RazorPagesTestSample": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "applicationUrl": "https://localhost:55954;http://localhost:55955"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj b/src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
index 34070413..1fd03db0 100644
--- a/src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
+++ b/src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
@@ -5,8 +5,8 @@
-
-
+
+
diff --git a/src/Application/src/RazorPagesTestSample/RazorPagesTestSample.sln b/src/Application/src/RazorPagesTestSample/RazorPagesTestSample.sln
index efe43ea0..e15697e2 100644
--- a/src/Application/src/RazorPagesTestSample/RazorPagesTestSample.sln
+++ b/src/Application/src/RazorPagesTestSample/RazorPagesTestSample.sln
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.4.33110.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPagesTestSample", "RazorPagesTestSample.csproj", "{BE1E794D-8E4A-4676-8711-A0DBF523EAE2}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPagesTestSample.Tests", "..\..\tests\RazorPagesTestSample.Tests\RazorPagesTestSample.Tests.csproj", "{67C04E03-38E8-4DCA-8670-AC6854D479DF}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
{BE1E794D-8E4A-4676-8711-A0DBF523EAE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE1E794D-8E4A-4676-8711-A0DBF523EAE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE1E794D-8E4A-4676-8711-A0DBF523EAE2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {67C04E03-38E8-4DCA-8670-AC6854D479DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {67C04E03-38E8-4DCA-8670-AC6854D479DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {67C04E03-38E8-4DCA-8670-AC6854D479DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {67C04E03-38E8-4DCA-8670-AC6854D479DF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/Application/tests/RazorPagesTestSample.Tests/Properties/launchSettings.json b/src/Application/tests/RazorPagesTestSample.Tests/Properties/launchSettings.json
new file mode 100644
index 00000000..866b3910
--- /dev/null
+++ b/src/Application/tests/RazorPagesTestSample.Tests/Properties/launchSettings.json
@@ -0,0 +1,12 @@
+{
+ "profiles": {
+ "RazorPagesTestSample.Tests": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "applicationUrl": "https://localhost:56864;http://localhost:56865"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj b/src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj
index a66e0a92..7addb37a 100644
--- a/src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj
+++ b/src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj
@@ -8,16 +8,16 @@
-
-
-
-
+
+
+
+
-
+
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/Application/tests/RazorPagesTestSample.Tests/UnitTests/DataAccessLayerTest.cs b/src/Application/tests/RazorPagesTestSample.Tests/UnitTests/DataAccessLayerTest.cs
index 91a91aaa..e24385ef 100644
--- a/src/Application/tests/RazorPagesTestSample.Tests/UnitTests/DataAccessLayerTest.cs
+++ b/src/Application/tests/RazorPagesTestSample.Tests/UnitTests/DataAccessLayerTest.cs
@@ -4,6 +4,7 @@
using Microsoft.EntityFrameworkCore;
using Xunit;
using RazorPagesTestSample.Data;
+using System.ComponentModel.DataAnnotations;
namespace RazorPagesTestSample.Tests.UnitTests
{
@@ -126,5 +127,48 @@ public async Task DeleteMessageAsync_NoMessageIsDeleted_WhenMessageIsNotFound()
}
}
#endregion
+
+ #region snippet5
+ [Theory]
+ [InlineData(150, true)]
+ [InlineData(199, true)]
+ [InlineData(200, true)]
+ [InlineData(201, true)]
+ [InlineData(249, true)]
+ [InlineData(250, true)]
+ [InlineData(251, false)]
+ [InlineData(300, false)]
+ public void Message_LengthValidation(int length, bool isValid)
+ {
+ // Arrange
+ var message = new Message
+ {
+ Id = 1,
+ Text = new string('a', length)
+ };
+
+ // Act
+ var validationResults = ValidateModel(message);
+
+ // Assert
+ if (isValid)
+ {
+ Assert.Empty(validationResults);
+ }
+ else
+ {
+ Assert.NotEmpty(validationResults);
+ Assert.Contains(validationResults, v => v.ErrorMessage.Contains("250 character limit"));
+ }
+ }
+
+ private IList ValidateModel(object model)
+ {
+ var validationResults = new List();
+ var validationContext = new ValidationContext(model, null, null);
+ Validator.TryValidateObject(model, validationContext, validationResults, true);
+ return validationResults;
+ }
+ #endregion
}
}