Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit e03bbb0

Browse files
committed
Convert TestsConsole to net5.0 Console App
1 parent 3d42b6f commit e03bbb0

File tree

4 files changed

+80
-69
lines changed

4 files changed

+80
-69
lines changed

tests/ServiceStack.Text.TestsConsole/App.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/ServiceStack.Text.TestsConsole/Program.cs

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
using System.Reflection.Emit;
66
using NUnit.Framework;
77
using ServiceStack.Common.Tests;
8+
using ServiceStack.OrmLite;
89
using ServiceStack.Reflection;
910

1011
namespace ServiceStack.Text.TestsConsole
1112
{
1213
class Program
1314
{
14-
static void Main(string[] args)
15+
public static void Main(string[] args)
1516
{
17+
PrintDumpColumnSchema();
18+
1619
//var da = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("dyn"), AssemblyBuilderAccess.Save);
1720

1821
//var dm = da.DefineDynamicModule("dyn_mod", "dyn.dll");
@@ -33,9 +36,9 @@ static void Main(string[] args)
3336
//dt.CreateType();
3437
//da.Save("dyn.dll");
3538

36-
new StringConcatPerfTests {
37-
MultipleIterations = new[] { 1000, 10000, 100000, 1000000, 10000000 }
38-
}.Compare_interpolation_vs_string_Concat();
39+
// new StringConcatPerfTests {
40+
// MultipleIterations = new[] { 1000, 10000, 100000, 1000000, 10000000 }
41+
// }.Compare_interpolation_vs_string_Concat();
3942

4043
Console.ReadLine();
4144
}
@@ -58,5 +61,73 @@ public void Compare_interpolation_vs_string_Concat()
5861
public static object SimpleFormat(string text) => string.Format("Hi {0}", text);
5962

6063
public static object SimpleConcat(string text) => "Hi " + text;
64+
65+
public static void PrintDumpColumnSchema()
66+
{
67+
var dbFactory = new OrmLiteConnectionFactory(":memory:",
68+
SqliteDialect.Provider);
69+
70+
using var db = dbFactory.Open();
71+
db.CreateTableIfNotExists<Person>();
72+
73+
ColumnSchema[] columnSchemas = db.GetTableColumns<Person>();
74+
75+
columnSchemas.Each(x => x.ToString().Print());
76+
columnSchemas.Each(x => x.PrintDump());
77+
}
78+
79+
public class Person
80+
{
81+
public static Person[] Rockstars = {
82+
new(1, "Jimi", "Hendrix", 27),
83+
new(2, "Janis", "Joplin", 27),
84+
new(3, "Jim", "Morrisson", 27),
85+
new(4, "Kurt", "Cobain", 27),
86+
new(5, "Elvis", "Presley", 42),
87+
new(6, "Michael", "Jackson", 50),
88+
};
89+
90+
public int Id { get; set; }
91+
public string FirstName { get; set; }
92+
public string LastName { get; set; }
93+
public int Age { get; set; }
94+
95+
public Person() { }
96+
public Person(int id, string firstName, string lastName, int age)
97+
{
98+
Id = id;
99+
FirstName = firstName;
100+
LastName = lastName;
101+
Age = age;
102+
}
103+
104+
protected bool Equals(Person other)
105+
{
106+
return Id == other.Id &&
107+
string.Equals(FirstName, other.FirstName) &&
108+
string.Equals(LastName, other.LastName) &&
109+
Age == other.Age;
110+
}
111+
112+
public override bool Equals(object obj)
113+
{
114+
if (ReferenceEquals(null, obj)) return false;
115+
if (ReferenceEquals(this, obj)) return true;
116+
if (obj.GetType() != this.GetType()) return false;
117+
return Equals((Person)obj);
118+
}
119+
120+
public override int GetHashCode()
121+
{
122+
unchecked
123+
{
124+
var hashCode = Id;
125+
hashCode = (hashCode * 397) ^ (FirstName != null ? FirstName.GetHashCode() : 0);
126+
hashCode = (hashCode * 397) ^ (LastName != null ? LastName.GetHashCode() : 0);
127+
hashCode = (hashCode * 397) ^ Age;
128+
return hashCode;
129+
}
130+
}
131+
}
61132
}
62133
}

tests/ServiceStack.Text.TestsConsole/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net45</TargetFramework>
5-
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
6-
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
7-
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
8-
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
9-
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
10-
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
11-
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
12-
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
4+
<TargetFramework>net5.0</TargetFramework>
135
</PropertyGroup>
146
<ItemGroup>
15-
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
17-
<PackageReference Include="NUnit" Version="3.10.1" />
7+
<!-- <PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />-->
8+
<!-- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />-->
9+
<!-- <PackageReference Include="NUnit" Version="3.10.1" />-->
1810
<ProjectReference Include="..\..\src\ServiceStack.Text\ServiceStack.Text.csproj" />
1911
<ProjectReference Include="..\ServiceStack.Text.Tests\ServiceStack.Text.Tests.csproj" />
2012
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
2113
<PackageReference Include="System.Memory" Version="4.5.4" />
2214
<PackageReference Include="ServiceStack" Version="$(Version)" />
23-
<Reference Include="System" />
24-
<Reference Include="System.Core" />
25-
<Reference Include="System.Xml.Linq" />
26-
<Reference Include="System.Data.DataSetExtensions" />
27-
<Reference Include="Microsoft.CSharp" />
28-
<Reference Include="System.Data" />
29-
<Reference Include="System.Net.Http" />
30-
<Reference Include="System.Xml" />
31-
</ItemGroup>
32-
<ItemGroup>
33-
<None Include="App.config" />
15+
<PackageReference Include="ServiceStack.OrmLite.Sqlite" Version="$(Version)" />
3416
</ItemGroup>
3517
</Project>

0 commit comments

Comments
 (0)