File tree Expand file tree Collapse file tree 3 files changed +77
-1
lines changed Expand file tree Collapse file tree 3 files changed +77
-1
lines changed Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+ <PropertyGroup >
3+ <TargetFramework >net9.0</TargetFramework >
4+ <LangVersion >latest</LangVersion >
5+ <ImplicitUsings >enable</ImplicitUsings >
6+ <Nullable >enable</Nullable >
7+ <IsPackable >false</IsPackable >
8+ </PropertyGroup >
9+ <ItemGroup >
10+ <PackageReference Include =" coverlet.collector" Version =" 6.0.2" />
11+ <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.12.0" />
12+ <PackageReference Include =" xunit" Version =" 2.9.2" />
13+ <PackageReference Include =" xunit.runner.visualstudio" Version =" 2.8.2" />
14+ </ItemGroup >
15+ <ItemGroup >
16+ <ProjectReference Include =" ..\SQLiteSharp\SQLiteSharp.csproj" />
17+ </ItemGroup >
18+ <ItemGroup >
19+ <Using Include =" Xunit" />
20+ </ItemGroup >
21+ </Project >
Original file line number Diff line number Diff line change 1+ namespace SQLiteSharp . Tests ;
2+
3+ public class UnitTest1 {
4+ [ Fact ]
5+ public void Test1 ( ) {
6+ // Open a database connection
7+ using SQLiteConnection Connection = new ( "database.db" ) ;
8+
9+ // Create a table for a class
10+ Connection . CreateTable < ShopItem > ( ) ;
11+
12+ // Delete all existing items in the table
13+ Connection . DeleteAll < ShopItem > ( ) ;
14+
15+ // Insert items into the table
16+ Connection . Insert ( new ShopItem ( ) {
17+ ItemName = "Apple" ,
18+ Count = 10 ,
19+ } ) ;
20+ Connection . Insert ( new ShopItem ( ) {
21+ ItemName = "Banana" ,
22+ Count = 5 ,
23+ } ) ;
24+
25+ // Find one item in the table matching a predicate
26+ ShopItem ? Apple = Connection . Find < ShopItem > ( ShopItem => ShopItem . ItemName == "Apple" ) ;
27+ Assert . NotNull ( Apple ) ;
28+
29+ // Delete an item from the table
30+ Connection . Delete ( Apple ) ;
31+
32+ // Find several items in the table
33+ List < ShopItem > Bananas = Connection . Table < ShopItem > ( ) . Where ( ShopItem => ShopItem . ItemName == "Banana" ) . ToList ( ) ;
34+ Assert . Single ( Bananas ) ;
35+ }
36+ }
37+
38+ public class ShopItem {
39+ [ PrimaryKey , AutoIncrement ]
40+ public long Id { get ; set ; }
41+
42+ [ NotNull ]
43+ public string ? ItemName { get ; set ; }
44+
45+ public long Count { get ; set ; }
46+
47+ [ Ignore ]
48+ public int SomethingToIgnore { get ; set ; }
49+ }
Original file line number Diff line number Diff line change 11
22Microsoft Visual Studio Solution File, Format Version 12.00
33# Visual Studio Version 17
4- VisualStudioVersion = 17.12.35521.163 d 17.12
4+ VisualStudioVersion = 17.12.35521.163
55MinimumVisualStudioVersion = 10.0.40219.1
66Project ("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" ) = "SQLiteSharp" , "SQLiteSharp\SQLiteSharp.csproj" , "{7BC2F0B1-3903-4D25-B65F-52D5C23D6B21}"
77EndProject
8+ Project ("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" ) = "SQLiteSharp.Tests" , "SQLiteSharp.Tests\SQLiteSharp.Tests.csproj" , "{61A33B8B-5810-4970-8C09-28E773ABE40F}"
9+ EndProject
810Global
911 GlobalSection (SolutionConfigurationPlatforms ) = preSolution
1012 Debug| Any CPU = Debug| Any CPU
@@ -15,6 +17,10 @@ Global
1517 {7BC2F0B1-3903-4D25-B65F-52D5C23D6B21} .Debug| Any CPU .Build .0 = Debug| Any CPU
1618 {7BC2F0B1-3903-4D25-B65F-52D5C23D6B21} .Release| Any CPU .ActiveCfg = Release| Any CPU
1719 {7BC2F0B1-3903-4D25-B65F-52D5C23D6B21} .Release| Any CPU .Build .0 = Release| Any CPU
20+ {61A33B8B-5810-4970-8C09-28E773ABE40F} .Debug| Any CPU .ActiveCfg = Debug| Any CPU
21+ {61A33B8B-5810-4970-8C09-28E773ABE40F} .Debug| Any CPU .Build .0 = Debug| Any CPU
22+ {61A33B8B-5810-4970-8C09-28E773ABE40F} .Release| Any CPU .ActiveCfg = Release| Any CPU
23+ {61A33B8B-5810-4970-8C09-28E773ABE40F} .Release| Any CPU .Build .0 = Release| Any CPU
1824 EndGlobalSection
1925 GlobalSection (SolutionProperties ) = preSolution
2026 HideSolutionNode = FALSE
You can’t perform that action at this time.
0 commit comments