-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ksqlDb.RestApi.Client]: added EntityTypeBuilder unit tests
- Loading branch information
1 parent
40a3628
commit cb153b9
Showing
1 changed file
with
91 additions
and
0 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
Tests/ksqlDB.RestApi.Client.Tests/FluentAPI/Builders/EntityTypeBuilderTests.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,91 @@ | ||
using FluentAssertions; | ||
using ksqlDb.RestApi.Client.FluentAPI.Builders; | ||
using ksqlDb.RestApi.Client.Metadata; | ||
using ksqlDb.RestApi.Client.Tests.Models; | ||
using NUnit.Framework; | ||
|
||
namespace ksqlDb.RestApi.Client.Tests.FluentAPI.Builders | ||
{ | ||
public class EntityTypeBuilderTests | ||
{ | ||
private EntityTypeBuilder<Tweet> builder = null!; | ||
|
||
[SetUp] | ||
public void TestInitialize() | ||
{ | ||
builder = new(); | ||
} | ||
|
||
[Test] | ||
public void HasKey() | ||
{ | ||
//Arrange | ||
|
||
//Act | ||
var entityTypeBuilder = builder.HasKey(c => c.Id); | ||
|
||
//Assert | ||
entityTypeBuilder.Should().NotBeNull(); | ||
((EntityTypeBuilder)entityTypeBuilder).Metadata.PrimaryKeyMemberInfo.Should().NotBeNull(); | ||
} | ||
|
||
[Test] | ||
public void Property() | ||
{ | ||
//Arrange | ||
|
||
//Act | ||
var fieldTypeBuilder = builder.Property(c => c.Id); | ||
|
||
//Assert | ||
fieldTypeBuilder.Should().NotBeNull(); | ||
builder.Metadata.FieldsMetadata.Count().Should().Be(2); | ||
} | ||
|
||
[Test] | ||
public void RowTime_Property_ShouldBeIgnoredInDDL() | ||
{ | ||
//Arrange | ||
|
||
//Act | ||
var fieldTypeBuilder = builder.Property(c => c.Id); | ||
|
||
//Assert | ||
fieldTypeBuilder.Should().NotBeNull(); | ||
builder.Metadata.FieldsMetadata.First(c => c.MemberInfo.Name == nameof(Tweet.RowTime)).IgnoreInDDL.Should().BeTrue(); | ||
} | ||
|
||
public class Foo | ||
{ | ||
public long RowTime; | ||
} | ||
|
||
[Test] | ||
public void RowTime_Field_ShouldBeIgnoredInDDL() | ||
{ | ||
//Arrange | ||
|
||
//Act | ||
EntityTypeBuilder<Foo> fooBuilder = new(); | ||
|
||
//Assert | ||
fooBuilder.Metadata.FieldsMetadata.First(c => c.MemberInfo.Name == nameof(Foo.RowTime)).IgnoreInDDL.Should().BeTrue(); | ||
} | ||
|
||
[Test] | ||
public void DecimalType_ShouldHaveDecimalFieldMetadata() | ||
{ | ||
//Arrange | ||
|
||
//Act | ||
var fieldTypeBuilder = builder.Property(c => c.AccountBalance); | ||
|
||
//Assert | ||
fieldTypeBuilder.Should().NotBeNull(); | ||
builder.Metadata.FieldsMetadata | ||
.OfType<DecimalFieldMetadata>() | ||
.First(c => c.MemberInfo.Name == nameof(Tweet.AccountBalance)) | ||
.Should().NotBeNull(); | ||
} | ||
} | ||
} |