Skip to content

Commit 65a0479

Browse files
committed
Added basic DBreeze-Implementation, Updated AspNetCore for the AspNetCore-based examples (prev. versions hat a theoretical security-flaw, because kestrel was vulnerable for ddos-attacks - though Kestrel is officially advised to be used behind a proxy...)
1 parent c405f72 commit 65a0479

File tree

14 files changed

+675
-11
lines changed

14 files changed

+675
-11
lines changed

THIRD_PARTY_LICENCES

+15-1
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,18 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
273273
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
274274
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
275275
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
277+
278+
#################################################################################
279+
Applies to: DBreeze
280+
#################################################################################
281+
opyright (c) 2012, dbreeze.tiesky.com tiesky.com
282+
All rights reserved.
283+
284+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
285+
286+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
287+
288+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
289+
290+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

src/AspNetCore/FluiTec.AppFx.AspNetCore.Examples.AuthExample/FluiTec.AppFx.AspNetCore.Examples.AuthExample.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
<ItemGroup>
1010
<PackageReference Include="FluiTec.AppFx.AspNetCore" Version="1.0.47" />
11-
<PackageReference Include="Localization.AspNetCore.TagHelpers" Version="0.3.0" />
12-
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
13-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" />
11+
<PackageReference Include="Localization.AspNetCore.TagHelpers" Version="0.5.0" />
12+
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.5" />
13+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.5" />
1414
<PackageReference Include="PaulMiami.AspNetCore.Mvc.Recaptcha" Version="1.2.1" />
1515
</ItemGroup>
1616

src/AspNetCore/FluiTec.AppFx.AspNetCore.Examples.LocalizationExample/FluiTec.AppFx.AspNetCore.Examples.LocalizationExample.csproj

+3-6
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8+
<PackageReference Include="DbLocalizationProvider.Abstractions" Version="4.2.16" />
9+
<PackageReference Include="FluiTec.AppFx.AspNetCore" Version="1.0.62" />
10+
<PackageReference Include="FluiTec.AppFx.Localization.LiteDb" Version="1.0.22" />
811
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
912
</ItemGroup>
1013

1114
<ItemGroup>
1215
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" />
1316
</ItemGroup>
1417

15-
<ItemGroup>
16-
<ProjectReference Include="..\FluiTec.AppFx.AspNetCore\FluiTec.AppFx.AspNetCore.csproj" />
17-
<ProjectReference Include="..\FluiTec.AppFx.Localization.LiteDb\FluiTec.AppFx.Localization.LiteDb.csproj" />
18-
<ProjectReference Include="..\LocalizationProvider\src\DbLocalizationProvider.Abstractions\DbLocalizationProvider.Abstractions.csproj" />
19-
</ItemGroup>
20-
2118
</Project>

src/AspNetCore/FluiTec.AspNetCore.Examples.AuthExampleClient/FluiTec.AspNetCore.Examples.AuthExampleClient.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<ItemGroup>
88
<PackageReference Include="FluiTec.AppFx.OpenId" Version="1.0.2" />
9-
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
9+
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.5" />
1010
</ItemGroup>
1111

1212
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
using System;
2+
using System.Linq;
3+
using FluiTec.AppFx.Data.LiteDb.Test.Fixtures;
4+
using Microsoft.VisualStudio.TestTools.UnitTesting;
5+
6+
namespace FluiTec.AppFx.Data.LiteDb.Test
7+
{
8+
[TestClass]
9+
public class DummyRepositoryTest
10+
{
11+
protected IDataService DataService { get; set; }
12+
protected IUnitOfWork UnitOfWork { get; set; }
13+
protected IDummyRepository Repository { get; set; }
14+
15+
public virtual void Initialize()
16+
{
17+
if (DataService != null)
18+
{
19+
DataService.Dispose();
20+
DataService = null;
21+
}
22+
23+
if (UnitOfWork != null)
24+
{
25+
UnitOfWork.Dispose();
26+
UnitOfWork = null;
27+
}
28+
29+
DataService = new DummyLiteDbDataService();
30+
DataService.RegisterRepositoryProvider(
31+
new Func<IUnitOfWork, IDummyRepository>(work => new DummyRepository(work)));
32+
UnitOfWork = DataService.BeginUnitOfWork();
33+
Repository = UnitOfWork.GetRepository<IDummyRepository>();
34+
}
35+
36+
public virtual void Cleanup()
37+
{
38+
Repository = null;
39+
UnitOfWork?.Dispose();
40+
DataService?.Dispose();
41+
}
42+
43+
[TestMethod]
44+
public void CanAddEntity()
45+
{
46+
Initialize();
47+
try
48+
{
49+
const string name = "My TestName";
50+
var entity = new DummyEntity {Name = name};
51+
52+
entity = Repository.Add(entity);
53+
entity = Repository.Get(entity.Id);
54+
55+
Assert.AreEqual(entity.Name, name);
56+
}
57+
finally
58+
{
59+
Cleanup();
60+
}
61+
}
62+
63+
[TestMethod]
64+
public void CanAddEntityRange()
65+
{
66+
Initialize();
67+
try
68+
{
69+
var originalCount = Repository.GetAll().Count();
70+
71+
var entities = new[] {new DummyEntity(), new DummyEntity()};
72+
Repository.AddRange(entities);
73+
var repoCount = Repository.GetAll().Count();
74+
75+
Assert.IsTrue(repoCount + originalCount >= entities.Length);
76+
}
77+
finally
78+
{
79+
Cleanup();
80+
}
81+
}
82+
83+
[TestMethod]
84+
public void CanUpdateEntity()
85+
{
86+
Initialize();
87+
try
88+
{
89+
const string updateName = "updated name";
90+
91+
var entity = new DummyEntity();
92+
entity = Repository.Add(entity);
93+
94+
entity.Name = updateName;
95+
entity = Repository.Update(entity);
96+
97+
Assert.AreEqual(updateName, entity.Name);
98+
}
99+
finally
100+
{
101+
Cleanup();
102+
}
103+
}
104+
105+
[TestMethod]
106+
public void CanDeleteByInstance()
107+
{
108+
Initialize();
109+
try
110+
{
111+
var entity = new DummyEntity();
112+
entity = Repository.Add(entity);
113+
114+
Repository.Delete(entity);
115+
116+
Assert.IsNull(Repository.Get(entity.Id));
117+
}
118+
finally
119+
{
120+
Cleanup();
121+
}
122+
}
123+
124+
[TestMethod]
125+
public void CanDeleteById()
126+
{
127+
Initialize();
128+
try
129+
{
130+
var entity = new DummyEntity();
131+
entity = Repository.Add(entity);
132+
133+
Repository.Delete(entity.Id);
134+
135+
Assert.IsNull(Repository.Get(entity.Id));
136+
}
137+
finally
138+
{
139+
Cleanup();
140+
}
141+
}
142+
143+
[TestMethod]
144+
public void TestCommit()
145+
{
146+
Initialize();
147+
try
148+
{
149+
foreach (var entry in Repository.GetAll()) Repository.Delete(entry);
150+
Repository.Add(new DummyEntity());
151+
UnitOfWork.Commit();
152+
}
153+
finally
154+
{
155+
Cleanup();
156+
}
157+
158+
Initialize();
159+
160+
try
161+
{
162+
Assert.AreEqual(1, Repository.GetAll().Count());
163+
foreach (var entry in Repository.GetAll()) Repository.Delete(entry);
164+
UnitOfWork.Commit();
165+
}
166+
finally
167+
{
168+
Cleanup();
169+
}
170+
}
171+
}
172+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace FluiTec.AppFx.Data.Dbreeze.Test.Fixtures
2+
{
3+
/// <summary> A dummy mssql data service. </summary>
4+
public class DummyDbreezeDataService : DbreezeDataService
5+
{
6+
/// <summary> Default constructor. </summary>
7+
public DummyDbreezeDataService() : base("FluiTec/AppFx")
8+
{
9+
}
10+
11+
/// <summary> The name. </summary>
12+
public override string Name => "DummyDbreezeDataService";
13+
14+
public override bool CanMigrate() => false;
15+
16+
public override void Migrate() => throw new System.NotImplementedException();
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace FluiTec.AppFx.Data.Dbreeze.Test.Fixtures
2+
{
3+
/// <summary> A dummy entity. </summary>
4+
[EntityName("Dummy")]
5+
public class DummyEntity : IEntity<int>
6+
{
7+
/// <summary> Gets or sets the name. </summary>
8+
/// <value> The name. </value>
9+
public string Name { get; set; }
10+
11+
/// <summary> Gets or sets the identifier. </summary>
12+
/// <value> The identifier. </value>
13+
public int Id { get; set; }
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace FluiTec.AppFx.Data.Dbreeze.Test.Fixtures
2+
{
3+
/// <summary> A dummy repository. </summary>
4+
public class DummyRepository : LiteDbIntegerRepository<DummyEntity>, IDummyRepository
5+
{
6+
/// <summary> Constructor. </summary>
7+
/// <param name="unitOfWork"> The unit of work. </param>
8+
public DummyRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
9+
{
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace FluiTec.AppFx.Data.Dbreeze.Test.Fixtures
2+
{
3+
/// <summary> Interface for dummy repository. </summary>
4+
public interface IDummyRepository : IDataRepository<DummyEntity, int>
5+
{
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
12+
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\FluiTec.AppFx.Data.Dbreeze\FluiTec.AppFx.Data.Dbreeze.csproj" />
17+
<ProjectReference Include="..\FluiTec.AppFx.Data.Test\FluiTec.AppFx.Data.Test.csproj" />
18+
<ProjectReference Include="..\FluiTec.AppFx.Data\FluiTec.AppFx.Data.csproj" />
19+
</ItemGroup>
20+
21+
</Project>

0 commit comments

Comments
 (0)