From 4c5df72057fe02257e243de37930a47425a84722 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Wed, 19 Feb 2025 02:05:39 +0800 Subject: chore(docker): remove crupest-api, forgejo and move dropped. --- .../Crud/CrudServiceTest.cs | 77 ---------------------- 1 file changed, 77 deletions(-) delete mode 100644 dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudServiceTest.cs (limited to 'dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudServiceTest.cs') diff --git a/dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudServiceTest.cs b/dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudServiceTest.cs deleted file mode 100644 index ad0d34c..0000000 --- a/dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudServiceTest.cs +++ /dev/null @@ -1,77 +0,0 @@ -using CrupestApi.Commons.Crud.Migrations; -using Microsoft.Extensions.Logging.Abstractions; - -namespace CrupestApi.Commons.Crud.Tests; - -public class CrudServiceTest -{ - private readonly SqliteMemoryConnectionFactory _memoryConnectionFactory = new SqliteMemoryConnectionFactory(); - - private readonly CrudService _crudService; - - public CrudServiceTest() - { - var columnTypeProvider = new ColumnTypeProvider(); - var tableInfoFactory = new TableInfoFactory(columnTypeProvider, NullLoggerFactory.Instance); - var dbConnectionFactory = new SqliteMemoryConnectionFactory(); - - _crudService = new CrudService( - tableInfoFactory, dbConnectionFactory, new SqliteDatabaseMigrator(), NullLoggerFactory.Instance); - } - - [Fact] - public void CrudTest() - { - var key = _crudService.Create(new TestEntity() - { - Name = "crupest", - Age = 18, - }); - - Assert.Equal("crupest", key); - - var entity = _crudService.GetByKey(key); - Assert.Equal("crupest", entity.Name); - Assert.Equal(18, entity.Age); - Assert.Null(entity.Height); - Assert.NotEmpty(entity.Secret); - - var list = _crudService.GetAll(); - entity = Assert.Single(list); - Assert.Equal("crupest", entity.Name); - Assert.Equal(18, entity.Age); - Assert.Null(entity.Height); - Assert.NotEmpty(entity.Secret); - - var count = _crudService.GetCount(); - Assert.Equal(1, count); - - _crudService.UpdateByKey(key, new TestEntity() - { - Name = "crupest2.0", - Age = 22, - Height = 180, - }); - - entity = _crudService.GetByKey("crupest2.0"); - Assert.Equal("crupest2.0", entity.Name); - Assert.Equal(22, entity.Age); - Assert.Equal(180, entity.Height); - Assert.NotEmpty(entity.Secret); - - _crudService.DeleteByKey("crupest2.0"); - - count = _crudService.GetCount(); - Assert.Equal(0, count); - } - - [Fact] - public void EntityNotExistTest() - { - Assert.Throws(() => _crudService.GetByKey("KeyNotExist")); - Assert.Throws(() => _crudService.UpdateByKey("KeyNotExist", new TestEntity - { - Name = "crupest" - })); - } -} -- cgit v1.2.3