Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
asherber committed Jun 9, 2022
2 parents 1aaa42e + 745e71a commit 6cf9335
Show file tree
Hide file tree
Showing 12 changed files with 1,822 additions and 30 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI
on: [ push, pull_request, workflow_dispatch ]
env:
DOTNET_NOLOGO: 1
jobs:
Build:
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Restore cache
uses: actions/cache@v2
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Build
run: dotnet build

- name: Test
run: dotnet test --no-build -v normal --logger trx

- name: Publish unit test report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Unit Test Report
path: '**/*.trx'
reporter: dotnet-trx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning">
<Version>3.3.37</Version>
<Version>3.5.107</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Icon](https://github.com/asherber/StaTypPocoQueries.PetaPoco/raw/master/media/static-64.png)
![Icon](https://raw.githubusercontent.com/asherber/StaTypPocoQueries.PetaPoco/main/media/static-64.png)

# StaTypPocoQueries.PetaPoco [![NuGet](https://img.shields.io/nuget/v/StaTypPocoQueries.PetaPoco.svg)](https://nuget.org/packages/StaTypPocoQueries.PetaPoco)
# StaTypPocoQueries.PetaPoco [![NuGet](https://img.shields.io/nuget/v/StaTypPocoQueries.PetaPoco.svg)](https://nuget.org/packages/StaTypPocoQueries.PetaPoco) [![CI](https://github.com/asherber/StaTypPocoQueries.PetaPoco/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/asherber/StaTypPocoQueries.PetaPoco/actions?query=branch%3A+main)

[PetaPoco](https://github.com/CollaboratingPlatypus/PetaPoco) bindings for [StaTypPocoQueries](https://github.com/d-p-y/statically-typed-poco-queries), allowing you to use some simple, strongly typed, Intellisensed LINQ expressions in your queries.

Expand Down
50 changes: 50 additions & 0 deletions StaTypPocoQueries.PetaPoco.Tests/OverridenPropertyTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using AutoFixture.Xunit2;
using FluentAssertions;
using Moq;
using PetaPoco;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace StaTypPocoQueries.PetaPoco.Tests
{
[Collection("TestsWithMappers")]
public class OverridenPropertyTests
{
public class Parent
{
public virtual int ID { get; set; }
}

public class Child : Parent
{
[Column("Foo")]
public override int ID { get; set; }
}

protected Mock<IDatabase> _mockDb;
protected Sql _lastSql;

public OverridenPropertyTests()
{
_mockDb = new Mock<IDatabase>();
_mockDb.Setup(m => m.Query<Child>(It.IsAny<Sql>()))
.Returns(new List<Child>())
.Callback<Sql>(s => _lastSql = s);
_mockDb.Setup(m => m.Provider).Returns(new AngleDatabaseProvider());
_mockDb.Setup(m => m.DefaultMapper).Returns(new ConventionMapper());

Mappers.RevokeAll();
}

[Theory, AutoData]
public void Query_Should_Use_Correct_Column_Attribute(int value)
{
_mockDb.Object.Query<Child>(c => c.ID == value);
_lastSql.Should().BeEquivalentTo(new Sql("WHERE <Foo> = @0", value));
}
}
}
1 change: 1 addition & 0 deletions StaTypPocoQueries.PetaPoco.Tests/QueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace StaTypPocoQueries.PetaPoco.Tests
* just to test that. Delete needs to be tested separately.
*/

[Collection("TestsWithMappers")]
public class QueryTests
{
private class MyClass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net462</TargetFrameworks>

<IsPackable>false</IsPackable>
<TargetFrameworks>net6.0;net462</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.8.0" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.8.0" />
<PackageReference Include="FluentAssertions" Version="5.5.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="PetaPoco.Compiled" Version="6.0.394" />
<PackageReference Include="xunit" Version="2.4.0" />
Expand Down
Loading

0 comments on commit 6cf9335

Please sign in to comment.