summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Matei Pintilie <luca@lucamatei.com>2024-10-30 20:59:53 +0000
committerLuca Matei Pintilie <luca@lucamatei.com>2024-10-30 20:59:53 +0000
commitdc1938dbb98dc9edf16558e505b2961246c83e6e (patch)
tree7953186976085ceca6c03a208d1ffd9596f745be
parentfc3c7e3b3c955cc274d4668768466fecb8fb727b (diff)
downloadwikiwaka-dc1938dbb98dc9edf16558e505b2961246c83e6e.tar
wikiwaka-dc1938dbb98dc9edf16558e505b2961246c83e6e.tar.gz
wikiwaka-dc1938dbb98dc9edf16558e505b2961246c83e6e.tar.bz2
wikiwaka-dc1938dbb98dc9edf16558e505b2961246c83e6e.tar.lz
wikiwaka-dc1938dbb98dc9edf16558e505b2961246c83e6e.tar.xz
wikiwaka-dc1938dbb98dc9edf16558e505b2961246c83e6e.tar.zst
wikiwaka-dc1938dbb98dc9edf16558e505b2961246c83e6e.zip
Add API and TestHEADmaster
-rw-r--r--.gitignore484
-rw-r--r--Api/Api.csproj15
-rw-r--r--Api/Contract/NewContent.cs7
-rw-r--r--Api/Contract/WikiPage.cs7
-rw-r--r--Api/Contract/WikiProperty.cs8
-rw-r--r--Api/Controllers/ContentApi.cs37
-rw-r--r--Api/Models/Content.cs7
-rw-r--r--Api/Models/DbWikiWakaContext.cs11
-rw-r--r--Api/Models/Language.cs7
-rw-r--r--Api/Models/Property.cs11
-rw-r--r--Api/Models/Version.cs6
-rw-r--r--Api/Program.cs38
-rw-r--r--Api/Properties/launchSettings.json41
-rw-r--r--Api/Utils/DbInit.cs25
-rw-r--r--Api/appsettings.Development.json8
-rw-r--r--Api/appsettings.json12
-rw-r--r--Api/databse.datbin0 -> 4096 bytes
-rw-r--r--Api/databse.dat-shmbin0 -> 32768 bytes
-rw-r--r--Api/databse.dat-walbin0 -> 45352 bytes
-rw-r--r--Tests/GlobalUsings.cs1
-rw-r--r--Tests/Tests.csproj23
-rw-r--r--Tests/UnitTest1.cs52
-rw-r--r--WikiWaka.sln28
23 files changed, 828 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..104b544
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,484 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from `dotnet new gitignore`
+
+# dotenv files
+.env
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# Tye
+.tye/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
+.idea
+
+##
+## Visual studio for Mac
+##
+
+
+# globs
+Makefile.in
+*.userprefs
+*.usertasks
+config.make
+config.status
+aclocal.m4
+install-sh
+autom4te.cache/
+*.tar.gz
+tarballs/
+test-results/
+
+# Mac bundle stuff
+*.dmg
+*.app
+
+# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
+# General
+.DS_Store
+.AppleDouble
+.LSOverride
+
+# Icon must end with two \r
+Icon
+
+
+# Thumbnails
+._*
+
+# Files that might appear in the root of a volume
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+.com.apple.timemachine.donotpresent
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
+# Windows thumbnail cache files
+Thumbs.db
+ehthumbs.db
+ehthumbs_vista.db
+
+# Dump file
+*.stackdump
+
+# Folder config file
+[Dd]esktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Windows Installer files
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# Windows shortcuts
+*.lnk
+
+# Vim temporary swap files
+*.swp
diff --git a/Api/Api.csproj b/Api/Api.csproj
new file mode 100644
index 0000000..ab1cb00
--- /dev/null
+++ b/Api/Api.csproj
@@ -0,0 +1,15 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+ <PropertyGroup>
+ <TargetFramework>net8.0</TargetFramework>
+ <Nullable>enable</Nullable>
+ <ImplicitUsings>enable</ImplicitUsings>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" />
+ <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
+ </ItemGroup>
+
+</Project>
diff --git a/Api/Contract/NewContent.cs b/Api/Contract/NewContent.cs
new file mode 100644
index 0000000..67a0019
--- /dev/null
+++ b/Api/Contract/NewContent.cs
@@ -0,0 +1,7 @@
+namespace WikiWaka.Api.Contract;
+
+public class NewContent
+{
+ public required string Text { get; set; }
+ public required string LanguageCode { get; set; }
+}
diff --git a/Api/Contract/WikiPage.cs b/Api/Contract/WikiPage.cs
new file mode 100644
index 0000000..0ea9d0a
--- /dev/null
+++ b/Api/Contract/WikiPage.cs
@@ -0,0 +1,7 @@
+namespace WikiWaka.Api.Contract;
+
+public class WikiPage
+{
+ public required int Id { get; init; }
+ public required WikiProperty Property { get; init; }
+}
diff --git a/Api/Contract/WikiProperty.cs b/Api/Contract/WikiProperty.cs
new file mode 100644
index 0000000..7f00812
--- /dev/null
+++ b/Api/Contract/WikiProperty.cs
@@ -0,0 +1,8 @@
+namespace WikiWaka.Api.Contract;
+
+public class WikiProperty
+{
+ public required int Id { get; init; }
+ public required string Text { get; set; }
+ public required string LanguageCode { get; set; }
+}
diff --git a/Api/Controllers/ContentApi.cs b/Api/Controllers/ContentApi.cs
new file mode 100644
index 0000000..757fd78
--- /dev/null
+++ b/Api/Controllers/ContentApi.cs
@@ -0,0 +1,37 @@
+using Microsoft.AspNetCore.Mvc;
+using WikiWaka.Api.Contract;
+using WikiWaka.Api.Models;
+
+namespace WikiWaka.Api.Controllers;
+
+[ApiController]
+[Route("[controller]")]
+public class ContentApiController(DbWikiWakaContext dbContext) : Controller
+{
+ [HttpGet(nameof(Content))]
+ public IAsyncEnumerable<Content> GetContents()
+ {
+ return dbContext.Content.AsAsyncEnumerable();
+ }
+
+ [HttpPost(nameof(Content))]
+ public async Task<Content> PostContents(NewContent newContent)
+ {
+ Language language = dbContext.Language.Single(l => l.LanguageCode == newContent.LanguageCode);
+ Content content = new();
+ Models.Version version = new();
+ Property property = new()
+ {
+ Content = content,
+ Language = language,
+ Version = version,
+ Text = newContent.Text,
+ };
+ await dbContext.Content.AddAsync(content);
+ await dbContext.Version.AddAsync(version);
+ await dbContext.Property.AddAsync(property);
+ await dbContext.SaveChangesAsync();
+
+ return content;
+ }
+}
diff --git a/Api/Models/Content.cs b/Api/Models/Content.cs
new file mode 100644
index 0000000..d59c8e1
--- /dev/null
+++ b/Api/Models/Content.cs
@@ -0,0 +1,7 @@
+namespace WikiWaka.Api.Models;
+
+public class Content
+{
+ public int Id { get; set; }
+ public ICollection<Property> Properties { get; set; }
+}
diff --git a/Api/Models/DbWikiWakaContext.cs b/Api/Models/DbWikiWakaContext.cs
new file mode 100644
index 0000000..cf5632a
--- /dev/null
+++ b/Api/Models/DbWikiWakaContext.cs
@@ -0,0 +1,11 @@
+using Microsoft.EntityFrameworkCore;
+
+namespace WikiWaka.Api.Models;
+
+public class DbWikiWakaContext(DbContextOptions options) : DbContext(options)
+{
+ public DbSet<Content> Content { get; set; }
+ public DbSet<Version> Version { get; set; }
+ public DbSet<Property> Property { get; set; }
+ public DbSet<Language> Language { get; set; }
+}
diff --git a/Api/Models/Language.cs b/Api/Models/Language.cs
new file mode 100644
index 0000000..a8fd30e
--- /dev/null
+++ b/Api/Models/Language.cs
@@ -0,0 +1,7 @@
+namespace WikiWaka.Api.Models;
+
+public class Language
+{
+ public int Id { get; set; }
+ public required string LanguageCode { get; set; }
+}
diff --git a/Api/Models/Property.cs b/Api/Models/Property.cs
new file mode 100644
index 0000000..b20adac
--- /dev/null
+++ b/Api/Models/Property.cs
@@ -0,0 +1,11 @@
+namespace WikiWaka.Api.Models;
+
+public class Property
+{
+ public int Id { get; set; }
+ public required string Text { get; set; }
+
+ public required Content Content { get; set; }
+ public required Language Language { get; set; }
+ public required Version Version { get; set; }
+}
diff --git a/Api/Models/Version.cs b/Api/Models/Version.cs
new file mode 100644
index 0000000..e4971e9
--- /dev/null
+++ b/Api/Models/Version.cs
@@ -0,0 +1,6 @@
+namespace WikiWaka.Api.Models;
+
+public class Version
+{
+ public int Id { get; set; }
+}
diff --git a/Api/Program.cs b/Api/Program.cs
new file mode 100644
index 0000000..0fefe46
--- /dev/null
+++ b/Api/Program.cs
@@ -0,0 +1,38 @@
+using Microsoft.EntityFrameworkCore;
+using WikiWaka.Api.Models;
+
+var builder = WebApplication.CreateBuilder(args);
+
+builder.Services.AddControllers();
+builder.Services.AddHealthChecks();
+builder.Services.AddEndpointsApiExplorer();
+builder.Services.AddSwaggerGen();
+builder.Services.AddDbContext<DbWikiWakaContext>(options =>
+ options.UseSqlite(builder.Configuration.GetConnectionString("DbWikiWaka")));
+
+var app = builder.Build();
+
+if (app.Environment.IsDevelopment())
+{
+ app.UseSwagger();
+ app.UseSwaggerUI();
+}
+
+app.MapControllers();
+app.MapHealthChecks("/healthz");
+
+using (var scope = app.Services.CreateScope())
+{
+ await using DbWikiWakaContext db = scope.ServiceProvider.GetRequiredService<DbWikiWakaContext>();
+ ILogger<Program> logger = scope.ServiceProvider.GetRequiredService<ILogger<Program>>();
+ bool isNewDatabase = await db.Database.EnsureCreatedAsync();
+ if (isNewDatabase)
+ {
+ logger.LogInformation("Creating new database...");
+ await DbInit.InitializeLanguages(db);
+ }
+ else
+ logger.LogInformation("Database existed before, not changing");
+}
+
+app.Run();
diff --git a/Api/Properties/launchSettings.json b/Api/Properties/launchSettings.json
new file mode 100644
index 0000000..63b924d
--- /dev/null
+++ b/Api/Properties/launchSettings.json
@@ -0,0 +1,41 @@
+{
+ "$schema": "http://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:16311",
+ "sslPort": 44364
+ }
+ },
+ "profiles": {
+ "http": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "applicationUrl": "http://localhost:5161",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "https": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "applicationUrl": "https://localhost:7140;http://localhost:5161",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/Api/Utils/DbInit.cs b/Api/Utils/DbInit.cs
new file mode 100644
index 0000000..0fc2d86
--- /dev/null
+++ b/Api/Utils/DbInit.cs
@@ -0,0 +1,25 @@
+using WikiWaka.Api.Models;
+
+public static class DbInit
+{
+ private static readonly Language[] languages = [
+ new() {
+ Id = 1,
+ LanguageCode = "nb-NO",
+ },
+ new() {
+ Id = 2,
+ LanguageCode = "nn-NO",
+ },
+ new() {
+ Id = 3,
+ LanguageCode = "en-US",
+ },
+ ];
+
+ public static async Task InitializeLanguages(DbWikiWakaContext db)
+ {
+ await db.Language.AddRangeAsync(languages);
+ _ = await db.SaveChangesAsync();
+ }
+}
diff --git a/Api/appsettings.Development.json b/Api/appsettings.Development.json
new file mode 100644
index 0000000..0c208ae
--- /dev/null
+++ b/Api/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/Api/appsettings.json b/Api/appsettings.json
new file mode 100644
index 0000000..2a784da
--- /dev/null
+++ b/Api/appsettings.json
@@ -0,0 +1,12 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*",
+ "ConnectionStrings": {
+ "DbWikiWaka": "Data Source=databse.dat"
+ }
+}
diff --git a/Api/databse.dat b/Api/databse.dat
new file mode 100644
index 0000000..9a47220
--- /dev/null
+++ b/Api/databse.dat
Binary files differ
diff --git a/Api/databse.dat-shm b/Api/databse.dat-shm
new file mode 100644
index 0000000..d7be745
--- /dev/null
+++ b/Api/databse.dat-shm
Binary files differ
diff --git a/Api/databse.dat-wal b/Api/databse.dat-wal
new file mode 100644
index 0000000..6bbfb28
--- /dev/null
+++ b/Api/databse.dat-wal
Binary files differ
diff --git a/Tests/GlobalUsings.cs b/Tests/GlobalUsings.cs
new file mode 100644
index 0000000..ab67c7e
--- /dev/null
+++ b/Tests/GlobalUsings.cs
@@ -0,0 +1 @@
+global using Microsoft.VisualStudio.TestTools.UnitTesting; \ No newline at end of file
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
new file mode 100644
index 0000000..5c37b71
--- /dev/null
+++ b/Tests/Tests.csproj
@@ -0,0 +1,23 @@
+<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="Microsoft.NET.Test.Sdk" Version="17.6.0" />
+ <PackageReference Include="MSTest.TestAdapter" Version="3.0.4" />
+ <PackageReference Include="MSTest.TestFramework" Version="3.0.4" />
+ <PackageReference Include="coverlet.collector" Version="6.0.0" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Api\Api.csproj" />
+ </ItemGroup>
+
+</Project>
diff --git a/Tests/UnitTest1.cs b/Tests/UnitTest1.cs
new file mode 100644
index 0000000..3e4dc64
--- /dev/null
+++ b/Tests/UnitTest1.cs
@@ -0,0 +1,52 @@
+using Microsoft.Data.Sqlite;
+using Microsoft.EntityFrameworkCore;
+using WikiWaka.Api.Controllers;
+using WikiWaka.Api.Models;
+
+namespace Tests;
+
+[TestClass]
+public class UnitTest1
+{
+ private ContentApiController controller;
+ private DbWikiWakaContext dbContext;
+
+ [TestInitialize]
+ public async Task TestInit()
+ {
+ SqliteConnection connection = new SqliteConnection("Filename=:memory:");
+ connection.Open();
+
+ var _contextOptions = new DbContextOptionsBuilder<DbWikiWakaContext>()
+ .UseSqlite(connection)
+ .Options;
+
+ dbContext = new(_contextOptions);
+ await dbContext.Database.EnsureCreatedAsync();
+ await DbInit.InitializeLanguages(dbContext);
+ controller = new(dbContext);
+ }
+
+ [TestCleanup]
+ public async Task TestClean()
+ {
+ await dbContext.Database.EnsureDeletedAsync();
+ await dbContext.DisposeAsync();
+ }
+
+ [TestMethod]
+ public async Task TestMethod1()
+ {
+ WikiWaka.Api.Contract.NewContent parameter = new()
+ {
+ Text = "Hello, world",
+ LanguageCode = "en-US",
+ };
+ Content newContent = await controller.PostContents(parameter);
+ IAsyncEnumerable<Content> contents = controller.GetContents();
+ Content newGetContent = contents.ToBlockingEnumerable().Single();
+
+ Assert.AreEqual(parameter.Text, newContent.Properties.Single().Text);
+ Assert.AreEqual(parameter.Text, newGetContent.Properties.Single().Text);
+ }
+}
diff --git a/WikiWaka.sln b/WikiWaka.sln
new file mode 100644
index 0000000..8ceacaf
--- /dev/null
+++ b/WikiWaka.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.31903.59
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api", "Api\Api.csproj", "{74D3ECFD-DBC5-4B8E-9B9B-43E0A9FF554C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{95940E6D-F0C2-4D0B-B4E6-A9F20640F9F8}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {74D3ECFD-DBC5-4B8E-9B9B-43E0A9FF554C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {74D3ECFD-DBC5-4B8E-9B9B-43E0A9FF554C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {74D3ECFD-DBC5-4B8E-9B9B-43E0A9FF554C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {74D3ECFD-DBC5-4B8E-9B9B-43E0A9FF554C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {95940E6D-F0C2-4D0B-B4E6-A9F20640F9F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {95940E6D-F0C2-4D0B-B4E6-A9F20640F9F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {95940E6D-F0C2-4D0B-B4E6-A9F20640F9F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {95940E6D-F0C2-4D0B-B4E6-A9F20640F9F8}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal