Skip to content

Commit

Permalink
Cleanup asserts (dotnet#32968)
Browse files Browse the repository at this point in the history
* Cleanup asserts

* Assert.True

* fixing compilation error

---------

Co-authored-by: maumar <maumar@microsoft.com>
  • Loading branch information
2 people authored and roji committed Feb 9, 2024
1 parent afd879d commit 5ece0ae
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ public Task Is_fixed_length_annotation_should_be_scaffolded_without_optional_par
new ModelCodeGenerationOptions { UseDataAnnotations = false },
code => Assert.Contains(".IsFixedLength()", code.ContextFile.Code),
model =>
Assert.Equal(true, model.FindEntityType("TestNamespace.Employee").GetProperty("Name").IsFixedLength()));
Assert.True(model.FindEntityType("TestNamespace.Employee").GetProperty("Name").IsFixedLength()));

[ConditionalFact]
public Task Global_namespace_works()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public virtual async Task Optional_json_properties_materialized_as_null_when_the
: query.Single();

Assert.Equal(3, result.Id);
Assert.Equal(null, result.Reference.NullableScalar);
Assert.Equal(null, result.Collection[0].NullableScalar);
Assert.Null(result.Reference.NullableScalar);
Assert.Null(result.Collection[0].NullableScalar);
}
}

Expand All @@ -107,8 +107,8 @@ public virtual async Task Can_project_nullable_json_property_when_the_element_in

Assert.Equal(3, result.Count);
Assert.Equal(11, result[0]);
Assert.Equal(null, result[1]);
Assert.Equal(null, result[2]);
Assert.Null(result[1]);
Assert.Null(result[2]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public virtual void Can_query_from_one_connection_and_save_changes_to_another()

[ConditionalTheory]
[InlineData(true, false)]
[InlineData(true, false)]
[InlineData(true, true)]
public virtual void Can_set_connection_string_in_interceptor(bool withConnectionString, bool withNullConnectionString)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,8 @@ public virtual Task Edit_single_property_bool()
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(false, result.Reference.TestBoolean);
Assert.Equal(true, result.Collection[0].TestBoolean);
Assert.False(result.Reference.TestBoolean);
Assert.True(result.Collection[0].TestBoolean);
});

[ConditionalFact]
Expand Down Expand Up @@ -1217,8 +1217,8 @@ public virtual Task Edit_single_property_nullable_int32_set_to_null()
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(null, result.Reference.TestNullableInt32);
Assert.Equal(null, result.Collection[0].TestNullableInt32);
Assert.Null(result.Reference.TestNullableInt32);
Assert.Null(result.Collection[0].TestNullableInt32);
});

[ConditionalFact]
Expand Down Expand Up @@ -1305,8 +1305,8 @@ public virtual Task Edit_single_property_nullable_enum_set_to_null()
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(null, result.Reference.TestNullableEnum);
Assert.Equal(null, result.Collection[0].TestNullableEnum);
Assert.Null(result.Reference.TestNullableEnum);
Assert.Null(result.Collection[0].TestNullableEnum);
});

[ConditionalFact]
Expand Down Expand Up @@ -1349,8 +1349,8 @@ public virtual Task Edit_single_property_nullable_enum_with_int_converter_set_to
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(null, result.Reference.TestNullableEnumWithIntConverter);
Assert.Equal(null, result.Collection[0].TestNullableEnumWithIntConverter);
Assert.Null(result.Reference.TestNullableEnumWithIntConverter);
Assert.Null(result.Collection[0].TestNullableEnumWithIntConverter);
});

[ConditionalFact]
Expand Down Expand Up @@ -1393,8 +1393,8 @@ public virtual Task Edit_single_property_nullable_enum_with_converter_that_handl
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(null, result.Reference.TestNullableEnumWithConverterThatHandlesNulls);
Assert.Equal(null, result.Collection[0].TestNullableEnumWithConverterThatHandlesNulls);
Assert.Null(result.Reference.TestNullableEnumWithConverterThatHandlesNulls);
Assert.Null(result.Collection[0].TestNullableEnumWithConverterThatHandlesNulls);
});

[ConditionalFact]
Expand Down Expand Up @@ -1522,7 +1522,7 @@ public virtual Task Edit_single_property_with_converter_bool_to_int_zero_one()
async context =>
{
var result = await context.Set<JsonEntityConverters>().SingleAsync(x => x.Id == 1);
Assert.Equal(false, result.Reference.BoolConvertedToIntZeroOne);
Assert.False(result.Reference.BoolConvertedToIntZeroOne);
});

[ConditionalFact]
Expand All @@ -1542,7 +1542,7 @@ public virtual Task Edit_single_property_with_converter_bool_to_string_True_Fals
async context =>
{
var result = await context.Set<JsonEntityConverters>().SingleAsync(x => x.Id == 1);
Assert.Equal(true, result.Reference.BoolConvertedToStringTrueFalse);
Assert.True(result.Reference.BoolConvertedToStringTrueFalse);
});

[ConditionalFact]
Expand All @@ -1562,7 +1562,7 @@ public virtual Task Edit_single_property_with_converter_bool_to_string_Y_N()
async context =>
{
var result = await context.Set<JsonEntityConverters>().SingleAsync(x => x.Id == 1);
Assert.Equal(false, result.Reference.BoolConvertedToStringYN);
Assert.False(result.Reference.BoolConvertedToStringYN);
});

[ConditionalFact]
Expand Down Expand Up @@ -2227,8 +2227,8 @@ public virtual Task Edit_single_property_collection_of_nullable_int32_set_to_nul
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(null, result.Reference.TestNullableInt32Collection);
Assert.Equal(null, result.Collection[0].TestNullableInt32Collection);
Assert.Null(result.Reference.TestNullableInt32Collection);
Assert.Null(result.Collection[0].TestNullableInt32Collection);

Assert.True(result.Reference.NewCollectionSet); // Set to null.
Assert.True(result.Collection[0].NewCollectionSet); // Set to null.
Expand Down Expand Up @@ -2327,8 +2327,8 @@ public virtual Task Edit_single_property_collection_of_nullable_enum_set_to_null
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(null, result.Reference.TestNullableEnumCollection);
Assert.Equal(null, result.Collection[0].TestNullableEnumCollection);
Assert.Null(result.Reference.TestNullableEnumCollection);
Assert.Null(result.Collection[0].TestNullableEnumCollection);

Assert.True(result.Reference.NewCollectionSet); // Set to null.
Assert.True(result.Collection[0].NewCollectionSet); // Set to null.
Expand Down Expand Up @@ -2383,8 +2383,8 @@ public virtual Task Edit_single_property_collection_of_nullable_enum_with_int_co
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(null, result.Reference.TestNullableEnumWithIntConverterCollection);
Assert.Equal(null, result.Collection[0].TestNullableEnumWithIntConverterCollection);
Assert.Null(result.Reference.TestNullableEnumWithIntConverterCollection);
Assert.Null(result.Collection[0].TestNullableEnumWithIntConverterCollection);

Assert.True(result.Reference.NewCollectionSet); // Set to null.
Assert.True(result.Collection[0].NewCollectionSet); // Set to null.
Expand Down Expand Up @@ -2434,8 +2434,8 @@ public virtual Task Edit_single_property_collection_of_nullable_enum_with_conver
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(null, result.Reference.TestNullableEnumWithConverterThatHandlesNullsCollection);
Assert.Equal(null, result.Collection[0].TestNullableEnumWithConverterThatHandlesNullsCollection);
Assert.Null(result.Reference.TestNullableEnumWithConverterThatHandlesNullsCollection);
Assert.Null(result.Collection[0].TestNullableEnumWithConverterThatHandlesNullsCollection);

Assert.False(result.Reference.NewCollectionSet);
Assert.False(result.Collection[0].NewCollectionSet);
Expand Down Expand Up @@ -2878,7 +2878,7 @@ public virtual Task Edit_single_property_relational_collection_of_nullable_int32
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(null, result.TestNullableInt32Collection);
Assert.Null(result.TestNullableInt32Collection);

Assert.True(result.NewCollectionSet); // Set to null.
});
Expand Down Expand Up @@ -2966,7 +2966,7 @@ public virtual Task Edit_single_property_relational_collection_of_nullable_enum_
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(null, result.TestNullableEnumCollection);
Assert.Null(result.TestNullableEnumCollection);

Assert.True(result.NewCollectionSet); // Set to null.
});
Expand Down Expand Up @@ -3013,7 +3013,7 @@ public virtual Task Edit_single_property_relational_collection_of_nullable_enum_
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(null, result.TestNullableEnumWithIntConverterCollection);
Assert.Null(result.TestNullableEnumWithIntConverterCollection);

Assert.True(result.NewCollectionSet); // Set to null.
});
Expand Down Expand Up @@ -3057,7 +3057,7 @@ public virtual Task Edit_single_property_relational_collection_of_nullable_enum_
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(null, result.TestNullableEnumWithConverterThatHandlesNullsCollection);
Assert.Null(result.TestNullableEnumWithConverterThatHandlesNullsCollection);

Assert.False(result.NewCollectionSet);
});
Expand Down
Loading

0 comments on commit 5ece0ae

Please sign in to comment.