Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/first-workflow.yml
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion src/Application/src/RazorPagesTestSample/Data/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"profiles": {
"RazorPagesTestSample": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:55954;http://localhost:55955"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.8" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"profiles": {
"RazorPagesTestSample.Tests": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:56864;http://localhost:56865"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@


<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.8" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.EntityFrameworkCore;
using Xunit;
using RazorPagesTestSample.Data;
using System.ComponentModel.DataAnnotations;

namespace RazorPagesTestSample.Tests.UnitTests
{
Expand Down Expand Up @@ -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<ValidationResult> ValidateModel(object model)
{
var validationResults = new List<ValidationResult>();
var validationContext = new ValidationContext(model, null, null);
Validator.TryValidateObject(model, validationContext, validationResults, true);
return validationResults;
}
#endregion
}
}
Loading