-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initialize HelloWorldMongoDb project with Docker support and tests #12
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/azds.yaml | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md | ||
!**/.gitignore | ||
!.git/HEAD | ||
!.git/config | ||
!.git/packed-refs | ||
!.git/refs/heads/** |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
| ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.11.35125.118 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloWorldMongoDb", "Src\HelloWorldMongoDb\HelloWorldMongoDb.csproj", "{4DC7A2B1-5EE5-4CB5-A506-9CB03C6CDF55}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Src", "Src", "{7ACF3968-951C-4742-B76F-CDF3A1862A6B}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{6A8AA32E-AA77-430D-9853-F6B689BA6F06}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorldMongoDb.Tests", "Tests\HelloWorldMongoDb.Tests\HelloWorldMongoDb.Tests.csproj", "{C6B2C984-D975-4C2B-866C-D28417334DDA}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{4DC7A2B1-5EE5-4CB5-A506-9CB03C6CDF55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4DC7A2B1-5EE5-4CB5-A506-9CB03C6CDF55}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4DC7A2B1-5EE5-4CB5-A506-9CB03C6CDF55}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4DC7A2B1-5EE5-4CB5-A506-9CB03C6CDF55}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{C6B2C984-D975-4C2B-866C-D28417334DDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C6B2C984-D975-4C2B-866C-D28417334DDA}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C6B2C984-D975-4C2B-866C-D28417334DDA}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C6B2C984-D975-4C2B-866C-D28417334DDA}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{4DC7A2B1-5EE5-4CB5-A506-9CB03C6CDF55} = {7ACF3968-951C-4742-B76F-CDF3A1862A6B} | ||
{C6B2C984-D975-4C2B-866C-D28417334DDA} = {6A8AA32E-AA77-430D-9853-F6B689BA6F06} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {0907E77B-B32E-40CA-9517-102D3F055C62} | ||
EndGlobalSection | ||
EndGlobal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. | ||
|
||
# This stage is used when running from VS in fast mode (Default for Debug configuration) | ||
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base | ||
USER app | ||
WORKDIR /app | ||
|
||
|
||
# This stage is used to build the service project | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
ARG BUILD_CONFIGURATION=Release | ||
WORKDIR /src | ||
COPY ["HelloWorldMongoDb/HelloWorldMongoDb.csproj", "HelloWorldMongoDb/"] | ||
RUN dotnet restore "./HelloWorldMongoDb/HelloWorldMongoDb.csproj" | ||
COPY . . | ||
WORKDIR "/src/HelloWorldMongoDb" | ||
RUN dotnet build "./HelloWorldMongoDb.csproj" -c $BUILD_CONFIGURATION -o /app/build | ||
|
||
# This stage is used to publish the service project to be copied to the final stage | ||
FROM build AS publish | ||
ARG BUILD_CONFIGURATION=Release | ||
RUN dotnet publish "./HelloWorldMongoDb.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false | ||
|
||
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration) | ||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
ENTRYPOINT ["dotnet", "HelloWorldMongoDb.dll"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" /> | ||
<PackageReference Include="MongoDB.Driver" Version="2.28.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace HelloWorldMongoDb; | ||
|
||
[ExcludeFromCodeCoverage] | ||
internal static class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine("Hello, World!"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"profiles": { | ||
"HelloWorldMongoDb": { | ||
"commandName": "Project" | ||
}, | ||
"Container (Dockerfile)": { | ||
"commandName": "Docker" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace HelloWorldMongoDb; | ||
|
||
public class Testable | ||
{ | ||
public bool TestableMethod() | ||
{ | ||
return true; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.msbuild" Version="6.0.2"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" /> | ||
<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> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Src\HelloWorldMongoDb\HelloWorldMongoDb.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="Xunit" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using FluentAssertions; | ||
|
||
namespace HelloWorldMongoDb.Tests; | ||
|
||
public class TestableTests | ||
{ | ||
[Fact] | ||
public void TestableMethod_StateUnderTest_ExpectedBehavior() | ||
{ | ||
// Arrange | ||
var testable = new Testable(); | ||
|
||
// Act | ||
var result = testable.TestableMethod(); | ||
|
||
// Assert | ||
result.Should().BeTrue(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using FluentAssertions; | ||
|
||
namespace HelloWorldMongoDb.Tests; | ||
|
||
public class UnitTest1 | ||
{ | ||
[Fact] | ||
public void Test1() | ||
{ | ||
// Arrange | ||
const bool expected = true; | ||
|
||
// Act | ||
var value = true; | ||
|
||
// Assert | ||
value.Should().Be(expected); | ||
} | ||
Comment on lines
+7
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Comment on lines
+5
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test case in the |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test class name 'UnitTest1' is too generic. It's recommended to use more descriptive names for test classes that indicate what functionality or component is being tested. This improves code readability and makes it easier to maintain your test suite. Consider renaming this class to something more specific that reflects the actual tests it contains.