Skip to content
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

VS-77: Add more enum test cases #35

Closed
wants to merge 4 commits into from

Conversation

Ravi-Raghavan
Copy link
Collaborator

Added more Enum Test Cases for LINQ covering situations where the Enum is in a variable and that variable is referenced in the query(i.e. either query syntax or the method invocation syntax).

Moved tests for Nullable Enums

Added more Enumerator Arithmetic Operation Test Cases

Added Test Cases for Unsupported Enum Operations
.Where(u => u.Vehicle.VehicleType.Type == vehicleType)
.Select(u => u.Vehicle.LicenceNumber);

VehicleTypeEnum? nullibleVehicleType = VehicleTypeEnum.Bus;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


_ = GetMongoQueryable<Person>()
.Where(u => u.Vehicle.VehicleType.Type == nullibleVehicleType)
.Select(u => u.Vehicle.LicenceNumber);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work in linq. So we need to generate mql.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created another ticket for Nullable support(i.e. VS-93) will implement changes in that ticket

var secondVehicleType = VehicleTypeEnum.Motorcylce;

_ = GetMongoQueryable<EnumHolder>()
.Where(u => u.EnumUInt64 == firstUnsignedEnum || u.EnumUInt64 == secondUnsignedEnum || u.EnumUInt64 == thirdUnsignedEnum)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest modifying the test to test all enum types (byte, short, etc) once in single statement.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -130,5 +130,15 @@ public void Query_syntax()
where ReturnArgument(ReturnArgument(ReturnArgument(this).ReturnArgument(person.Vehicle.VehicleType))).Type == VehicleTypeEnum.Bus
select person;
}

[InvalidLinq("Convert(Convert((Convert({document}{EnumInt16}, Int32) + 10), GenType_Enum_12), Int32) is not supported.")]
[InvalidLinq3("Cannot find serializer for Convert(u.EnumInt16, Int32).", version: "[2.14.0-beta1, 2.18.0)")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have constants for versions (DriverVersions)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

.Where(u => u.EnumInt64 == EnumInt64.Value0 + 35);

_ = GetMongoQueryable<EnumHolder>()
.Where(u => u.EnumInt64 == EnumInt64.Value0 - 35);
Copy link
Collaborator

@BorisDog BorisDog Jun 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add more test cases from here and here

@BorisDog BorisDog self-requested a review July 10, 2023 17:03
@@ -21,7 +21,13 @@ public static class DriverVersions
public const string Linq3NonDefault = "[2.14.0-beta1, 2.19.0)";
public const string Linq3DefaultAndHigher = V2_19_AndHigher;
public const string Linq2DefaultAndLower = V2_18_AndLower;

public const string V2_14_Beta1_Till_V2_18 = "[2.14.0-beta1, 2.18.0)";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used?

_ = GetMongoQueryable<EnumHolder>()
.Where(u => u.EnumInt32 == EnumInt32.Value0 - 25);

_ = GetMongoQueryable<EnumHolder>()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about left-hand operations: .Where(u => u.EnumInt32 + 123 == EnumInt32.Value0 - 25)

@Ravi-Raghavan Ravi-Raghavan deleted the VS-77 branch June 4, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants