Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tdwright committed Dec 21, 2017
2 parents fb048c6 + 20b839e commit 8cd2c3d
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 4 deletions.
13 changes: 12 additions & 1 deletion ConTabs.Tests/Table-Basic.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NUnit.Framework;
using Shouldly;
using System.Collections.Generic;
using ConTabs.Exceptions;
using ConTabs.TestData;

namespace ConTabs.Tests
Expand Down Expand Up @@ -43,7 +44,17 @@ public void TableObjectHasExpectedNumberOfColumns()
// Assert
table.Columns.Count.ShouldBe(4);
}


[Test]
public void Table_GivenClassWithoutPublicProperties_ThrowsPublicPropertiesNotFoundException()
{
// Arrange
var listOfTestClasses = DataProvider.ListOfInvalidTestData();

// Assert
Assert.Throws<PublicPropertiesNotFoundException>(() =>
Table<InvalidTestDataType>.Create(listOfTestClasses));
}
}


Expand Down
3 changes: 0 additions & 3 deletions ConTabs/ConTabs.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0;net45</TargetFrameworks>
<PackageId>ConTabs.tdwright</PackageId>
Expand All @@ -16,10 +15,8 @@ Additionally, the codebase has been extensively refactored. There is one breakin
<PackageProjectUrl>https://github.com/tdwright/contabs</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/tdwright/contabs/blob/master/LICENSE</PackageLicenseUrl>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>

</Project>
10 changes: 10 additions & 0 deletions ConTabs/Exceptions/PublicPropertiesNotFoundException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace ConTabs.Exceptions
{
public class PublicPropertiesNotFoundException : Exception
{
public override string Message =>
"On Table<T> creation, no valid properties were identified. Check access modifiers.";
}
}
3 changes: 3 additions & 0 deletions ConTabs/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using ConTabs.Exceptions;

namespace ConTabs
{
Expand Down Expand Up @@ -54,6 +55,8 @@ private Table()
.Where(p => p.GetMethod.IsPublic)
.Select(p => new Column(p.PropertyType, p.Name))
.ToList();

if (!Columns.Any()) throw new PublicPropertiesNotFoundException();
}

public override string ToString()
Expand Down
21 changes: 21 additions & 0 deletions ConTabsTestData/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ public static List<MinimalDataType> ListOfMinimalData(int? limit = null)
if (!limit.HasValue || limit < 0) limit = list.Count;
return list.Take(limit.Value).ToList();
}

public static List<InvalidTestDataType> ListOfInvalidTestData()
{
var list = new List<InvalidTestDataType>
{
new InvalidTestDataType(),
new InvalidTestDataType(),
new InvalidTestDataType(),
new InvalidTestDataType(),
};
return list;
}
}

public class TestDataType
Expand All @@ -47,4 +59,13 @@ public class MinimalDataType
public int IntA { get; set; }
public int IntB { get; set; }
}

public class InvalidTestDataType
{
private string StringColumn { get; set; }
private int IntColumn { get; set; }
private decimal CurrencyColumn { get; set; }
private DateTime DateTimeColumn { get; set; }
private string HiddenProp { get; set; }
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ This renders like this:

If you're interested in contributing, we'd love to welcome you. Check out our [contributing guidelines](CONTRIBUTING.md) which should contain everything you need to make a successful contribution.


## Background

ConTabs started life as an excuse for me (tdwright) to explore some bits and pieces. [I am writing up my experiences on my blog.](http://blog.tdwright.co.uk/series/modern-dotnet-dev-contabs/)
Binary file added RepoAssets/Example-Basic-Heavy.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8cd2c3d

Please sign in to comment.