-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moved WithObject to generated code, added FromTemplate #43
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Contributing | ||
|
||
This project welcomes issues and pull requests, although it is an opinionated project. There are many ways to approach this particular problem, and I (Mel Grubb) captured my own preferences when I started this project. | ||
|
||
# Building | ||
|
||
# Testing | ||
|
||
There are currently five test projects. | ||
- BuilderGenerator.Tests.Core: Defines the domain objects used by other test projects. | ||
- BuilderGenerator.Tests.Unit: Directly exercises the builder mechanism to provide fast feedback and verification. | ||
- BuilderGenerator.Tests.Integration.Net60: Uses the builder generator in a more real-world way to create builders for a sample Net 6 library project. | ||
- BuilderGenerator.Tests.Integration.Net70: Same thing, but targeting .Net 7 | ||
- BuilderGenerator.Tests.Integration.Net80: Same thing, but targeting .Net 8 |
11 changes: 0 additions & 11 deletions
11
src/BuilderGenerator.IntegrationTests.Core/Models/Entities/README.md
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
src/BuilderGenerator.IntegrationTests.Core/Models/Entities/_ReadMe.md
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
src/BuilderGenerator.IntegrationTests.Net60/Builders/CollectionTypeSampleBuilder.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s.Core/Models/Entities/AuditableEntity.cs → ...s.Core/Models/Entities/AuditableEntity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../Models/Entities/CollectionTypesSample.cs → .../Models/Entities/CollectionTypesSample.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ationTests.Core/Models/Entities/Entity.cs → ...ator.Tests.Core/Models/Entities/Entity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...rationTests.Core/Models/Entities/Order.cs → ...rator.Tests.Core/Models/Entities/Order.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...onTests.Core/Models/Entities/OrderItem.cs → ...r.Tests.Core/Models/Entities/OrderItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 2 additions & 8 deletions
10
...grationTests.Core/Models/Entities/User.cs → ...erator.Tests.Core/Models/Entities/User.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
#nullable enable | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace BuilderGenerator.IntegrationTests.Core.Models.Entities; | ||
namespace BuilderGenerator.Tests.Core.Models.Entities; | ||
|
||
public partial class User : AuditableEntity | ||
public class User : AuditableEntity | ||
{ | ||
public string FirstName { get; set; } | ||
public string LastName { get; set; } | ||
public string? MiddleName { get; set; } | ||
} | ||
|
||
public partial class User | ||
{ | ||
public ICollection<Order> Orders { get; set; } = new List<Order>(); | ||
} |
2 changes: 1 addition & 1 deletion
2
...ionTests.Core/Models/Enums/OrderStatus.cs → ...or.Tests.Core/Models/Enums/OrderStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Generator.IntegrationTests.Core/README.md → src/BuilderGenerator.Tests.Core/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# BuilderGenerator.Core # | ||
# BuilderGenerator.Tests.Core | ||
|
||
This project defines the object model used in the other framework-specific tests. It is defined as a netstandard2.0 library so that it can be used with the widest variety of consuming projects. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/BuilderGenerator.Tests.Integration.Net60/Builders/CollectionTypeSampleBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using BuilderGenerator.Tests.Core.Models.Entities; | ||
|
||
namespace BuilderGenerator.Tests.Integration.Net60.Builders; | ||
|
||
[BuilderFor(typeof(CollectionTypesSample))] | ||
public partial class CollectionTypeSampleBuilder | ||
{ | ||
} |
4 changes: 2 additions & 2 deletions
4
...ationTests.Net60/Builders/OrderBuilder.cs → ...ntegration.Net60/Builders/OrderBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...nTests.Net60/Builders/OrderItemBuilder.cs → ...ration.Net60/Builders/OrderItemBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...rationTests.Net60/Builders/UserBuilder.cs → ...Integration.Net60/Builders/UserBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...enerator.IntegrationTests.Net60/README.md → ...nerator.Tests.Integration.Net60/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# BuilderGenerator.Sample.Net60.FromProject | ||
# BuilderGenerator.Sample.Net70.FromProject | ||
|
||
This project provides tests the BuilderGenerator package being used in a .Net 6.0 project using a simple series of inter-related classes defined in the BuiderGenerator.Test.Core project. | ||
This project provides tests the BuilderGenerator package being used in a .Net 7.0 project using a simple series of inter-related classes defined in the BuiderGenerator.Test.Core project. | ||
|
||
The reference to the BuilderGenerator is a direct project reference, so it can be used to rapidly check the results of changes, but does not represent the real-world usage of the generator. It tests the functionality of the builder, but not the deployment mechanism. |
6 changes: 3 additions & 3 deletions
6
...egrationTests.Net60/Tests/BuilderTests.cs → ...s.Integration.Net60/Tests/BuilderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...ionTests.Net60/Tests/OrderBuilderTests.cs → ...egration.Net60/Tests/OrderBuilderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...tionTests.Net60/Tests/UserBuilderTests.cs → ...tegration.Net60/Tests/UserBuilderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/BuilderGenerator.Tests.Integration.Net70/BuilderGenerator.Tests.Integration.Net70.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\BuilderGenerator.Tests.Core\BuilderGenerator.Tests.Core.csproj" /> | ||
<ProjectReference Include="..\BuilderGenerator.Tests.Unit\BuilderGenerator.Tests.Unit.csproj" /> | ||
<ProjectReference Include="..\BuilderGenerator\BuilderGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" /> | ||
<PackageReference Include="NUnit" Version="3.13.3" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" /> | ||
<PackageReference Include="Shouldly" Version="4.2.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
8 changes: 8 additions & 0 deletions
8
src/BuilderGenerator.Tests.Integration.Net70/Builders/CollectionTypeSampleBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using BuilderGenerator.Tests.Core.Models.Entities; | ||
|
||
namespace BuilderGenerator.Tests.Integration.Net70.Builders; | ||
|
||
[BuilderFor(typeof(CollectionTypesSample))] | ||
public partial class CollectionTypeSampleBuilder | ||
{ | ||
} |
29 changes: 29 additions & 0 deletions
29
src/BuilderGenerator.Tests.Integration.Net70/Builders/OrderBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using BuilderGenerator.Tests.Core.Models.Entities; | ||
|
||
namespace BuilderGenerator.Tests.Integration.Net70.Builders; | ||
|
||
[BuilderFor(typeof(Order), true)] | ||
public partial class OrderBuilder | ||
{ | ||
public static OrderBuilder Simple() | ||
{ | ||
var builder = new OrderBuilder() | ||
.WithId(Guid.NewGuid); | ||
|
||
return builder; | ||
} | ||
|
||
public static OrderBuilder Typical() | ||
{ | ||
var builder = Simple() | ||
.WithItems( | ||
() => new List<OrderItem> | ||
{ | ||
OrderItemBuilder.Simple().Build(), | ||
}); | ||
|
||
return builder; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/BuilderGenerator.Tests.Integration.Net70/Builders/OrderItemBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using BuilderGenerator.Tests.Core.Models.Entities; | ||
|
||
namespace BuilderGenerator.Tests.Integration.Net70.Builders; | ||
|
||
[BuilderFor(typeof(OrderItem))] | ||
public partial class OrderItemBuilder | ||
{ | ||
public static OrderItemBuilder Simple() | ||
{ | ||
var builder = new OrderItemBuilder() | ||
.WithId(Guid.NewGuid); | ||
|
||
return builder; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/BuilderGenerator.Tests.Integration.Net70/Builders/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Partial Builders # | ||
|
||
This folder contains the hand-written half of any builders. Create static factory methods for each well-known or named object instance you want to create. | ||
|
||
## Suggestions ## | ||
|
||
In addition to specific factory methods, you should define some general-purpose methods such as: | ||
|
||
### Simple/Minimal ### | ||
|
||
Creates the simplest, most minimal instance that will pass validation. Only fill in the required fields, and leave everything else at their default values. This can serve as the starting point for other, more specific factory methods. For instance, a minimal Customer may be missing address information, and would have no orders. | ||
|
||
### Typical ### | ||
|
||
This method should return a "typical" example of the class. For a Customer entity, this might mean that the shipping and billing addresses are filled in, and the Customer has multiple orders in various states. |
32 changes: 32 additions & 0 deletions
32
src/BuilderGenerator.Tests.Integration.Net70/Builders/UserBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using BuilderGenerator.Tests.Core.Models.Entities; | ||
|
||
namespace BuilderGenerator.Tests.Integration.Net70.Builders; | ||
|
||
[BuilderFor(typeof(User))] | ||
public partial class UserBuilder | ||
{ | ||
public static UserBuilder Simple() | ||
{ | ||
var builder = new UserBuilder() | ||
.WithId(Guid.NewGuid) | ||
.WithFirstName(() => Guid.NewGuid().ToString()) | ||
.WithMiddleName(() => Guid.NewGuid().ToString()) | ||
.WithLastName(() => Guid.NewGuid().ToString()); | ||
|
||
return builder; | ||
} | ||
|
||
public static UserBuilder Typical() | ||
{ | ||
var builder = Simple() | ||
.WithOrders( | ||
() => new List<Order> | ||
{ | ||
OrderBuilder.Simple().Build(), | ||
}); | ||
|
||
return builder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# BuilderGenerator.Sample.Net70.FromProject | ||
|
||
This project provides tests the BuilderGenerator package being used in a .Net 7.0 project using a simple series of inter-related classes defined in the BuiderGenerator.Test.Core project. | ||
|
||
The reference to the BuilderGenerator is a direct project reference, so it can be used to rapidly check the results of changes, but does not represent the real-world usage of the generator. It tests the functionality of the builder, but not the deployment mechanism. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reorganized the tests quite a bit.