-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
163 additions
and
62 deletions.
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
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,74 @@ | ||
namespace JQLBuilder.Tests.Types; | ||
|
||
using Constants; | ||
using Infrastructure; | ||
using JQLBuilder.Types.JqlTypes; | ||
using FieldContestants = Constants.Fields; | ||
using Fields = Fields; | ||
|
||
[TestClass] | ||
public class ProjectTypeTests | ||
{ | ||
const string ProjectType = "software"; | ||
const string ExpectedProjectType = $@"""{ProjectType}"""; | ||
|
||
[TestMethod] | ||
public void Should_Cast_Project_Expression_From_String() | ||
{ | ||
var expression = (JqlProjectType)ProjectType; | ||
|
||
Assert.AreEqual("String", expression.Value.GetType().Name); | ||
Assert.AreEqual(ProjectType, expression.Value); | ||
} | ||
|
||
[TestMethod] | ||
public void Should_Cast_Project_Field() | ||
{ | ||
const string expected = FieldContestants.Project; | ||
|
||
var field = Fields.All.Project; | ||
var actual = ((Field)field.Value).Value; | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
public void Should_Parses_Equality_Operators() | ||
{ | ||
var expected = | ||
$"{FieldContestants.ProjectType} {Operators.Equals} {ExpectedProjectType} {Keywords.And} " + | ||
$"{FieldContestants.ProjectType} {Operators.NotEquals} {ExpectedProjectType} {Keywords.And} " + | ||
$"{FieldContestants.ProjectType} {Operators.Equals} {ExpectedProjectType} {Keywords.And} " + | ||
$"{FieldContestants.ProjectType} {Operators.NotEquals} {ExpectedProjectType}"; | ||
|
||
var actual = JqlBuilder.Query | ||
.Where(f => f.Project.Type == ProjectType) | ||
.And(f => f.Project.Type != ProjectType) | ||
.And(f => ProjectType == f.Project.Type) | ||
.And(f => ProjectType != f.Project.Type) | ||
.ToString(); | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
public void Should_Parses_Membership_Operators() | ||
{ | ||
var expected = | ||
$"{FieldContestants.ProjectType} {Operators.In} ({ExpectedProjectType}, {ExpectedProjectType}, {ExpectedProjectType}) {Keywords.And} " + | ||
$"{FieldContestants.ProjectType} {Operators.In} ({ExpectedProjectType}, {ExpectedProjectType}, {ExpectedProjectType}) {Keywords.And} " + | ||
$"{FieldContestants.ProjectType} {Operators.NotIn} ({ExpectedProjectType}, {ExpectedProjectType}, {ExpectedProjectType}) {Keywords.And} " + | ||
$"{FieldContestants.ProjectType} {Operators.NotIn} ({ExpectedProjectType}, {ExpectedProjectType}, {ExpectedProjectType})"; | ||
|
||
var homogeneousFilter = new JqlCollection<JqlProjectType> { ProjectType, ProjectType, ProjectType }; | ||
|
||
var actual = JqlBuilder.Query | ||
.Where(f => f.Project.Type.In(ProjectType, ProjectType, ProjectType)) | ||
.And(f => f.Project.Type.In(homogeneousFilter)) | ||
.And(f => f.Project.Type.NotIn(ProjectType, ProjectType, ProjectType)) | ||
.And(f => f.Project.Type.NotIn(homogeneousFilter)) | ||
.ToString(); | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
} |
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
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
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
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
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 @@ | ||
namespace JQLBuilder.Types; | ||
|
||
using Constants; | ||
using Infrastructure; | ||
using JqlTypes; | ||
|
||
public class IssueType : TypeField | ||
{ | ||
public IssueType() => Value = new Field(Fields.Type); | ||
|
||
public TypeField Issue { get; } = Field.Custom<TypeField>(Fields.IssueType); | ||
} | ||
|
||
public class OrderingIssueType : TypeField | ||
{ | ||
public OrderingIssueType() => Value = new Field(Fields.Type); | ||
|
||
public TypeField Issue { get; } = Field.Custom<TypeField>(Fields.IssueType); | ||
} |
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,21 @@ | ||
namespace JQLBuilder.Types.JqlTypes; | ||
|
||
using Abstract; | ||
using Infrastructure; | ||
using Infrastructure.Abstract; | ||
using Infrastructure.Operators; | ||
|
||
#pragma warning disable CS0660, CS0661 | ||
public class ProjectTypeField : JqlValue, IJqlField<JqlProjectType> | ||
#pragma warning restore CS0660, CS0661 | ||
{ | ||
public static Bool operator ==(ProjectTypeField left, JqlProjectType right) => left.Equal(right); | ||
public static Bool operator !=(ProjectTypeField left, JqlProjectType right) => left.NotEqual(right); | ||
public static Bool operator ==(JqlProjectType left, ProjectTypeField right) => right.Equal(left); | ||
public static Bool operator !=(JqlProjectType left, ProjectTypeField right) => right.NotEqual(left); | ||
} | ||
|
||
public class JqlProjectType : JqlValue, IJqlMembership<JqlProjectType> | ||
{ | ||
public static implicit operator JqlProjectType(string value) => new() { Value = value }; | ||
} |
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
This file was deleted.
Oops, something went wrong.