Skip to content

Commit

Permalink
No skipped tests in non-functional tests
Browse files Browse the repository at this point in the history
Part of #26088 and #17235
  • Loading branch information
ajcvickers committed Oct 25, 2021
1 parent f62cf1b commit 14dc6ce
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Conventions
{
public class CosmosConventionSetBuilderTests : ConventionSetBuilderTests
{
public override IReadOnlyModel Can_build_a_model_with_default_conventions_without_DI()
{
return null;
}

public override IReadOnlyModel Can_build_a_model_with_default_conventions_without_DI_new()
{
var model = base.Can_build_a_model_with_default_conventions_without_DI_new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit;
using Xunit.Sdk;

// ReSharper disable InconsistentNaming
namespace Microsoft.EntityFrameworkCore.ModelBuilding
Expand All @@ -18,17 +21,18 @@ public class CosmosGenericNonRelationship : GenericNonRelationship
{
public override void Properties_can_set_row_version()
{
// Fails due to ETags
Assert.Equal(
CosmosStrings.NonETagConcurrencyToken(nameof(Quarks), "Charm"),
Assert.Throws<InvalidOperationException>(
() => base.Properties_can_set_row_version()).Message);
}

public override void Properties_can_be_made_concurrency_tokens()
{
// Fails due to ETags
}

public override void Properties_specified_by_string_are_shadow_properties_unless_already_known_to_be_CLR_properties()
{
// Fails due to extra shadow properties
Assert.Equal(
CosmosStrings.NonETagConcurrencyToken(nameof(Quarks), "Charm"),
Assert.Throws<InvalidOperationException>(
() => base.Properties_can_be_made_concurrency_tokens()).Message);
}

protected override void Mapping_throws_for_non_ignored_array()
Expand Down Expand Up @@ -271,24 +275,29 @@ protected override TestModelBuilder CreateModelBuilder(Action<ModelConfiguration

public class CosmosGenericInheritance : GenericInheritance
{
public override void Can_set_and_remove_base_type()
{
// Fails due to presence of __jObject
}

public override void Base_type_can_be_discovered_after_creating_foreign_keys_on_derived()
{
// Base discovered as owned
}
var mb = CreateModelBuilder();
mb.Entity<AL>();
mb.Entity<L>();

public override void Base_types_are_mapped_correctly_if_discovered_last()
{
// Base discovered as owned
var mutableEntityTypes = mb.Model.GetEntityTypes().Where(e => e.ClrType == typeof(Q)).ToList();

Assert.Equal(2, mutableEntityTypes.Count);

foreach (var mutableEntityType in mutableEntityTypes)
{
var mutableProperty = mutableEntityType.FindProperty(nameof(Q.ID));

Assert.Equal(ValueGenerated.Never, mutableProperty.ValueGenerated);
}
}

public override void Relationships_on_derived_types_are_discovered_first_if_base_is_one_sided()
{
// Base discovered as owned
Assert.Throws<NullReferenceException>(
() => base.Relationships_on_derived_types_are_discovered_first_if_base_is_one_sided());
}

protected override TestModelBuilder CreateModelBuilder(Action<ModelConfigurationBuilder> configure = null)
Expand Down Expand Up @@ -488,12 +497,22 @@ public virtual void Can_use_implicit_join_entity_with_partition_keys_changed()

public override void Join_type_is_automatically_configured_by_convention()
{
// Many-to-many not configured by convention on Cosmos
// Cosmos many-to-many. Issue #23523.
Assert.Equal(
CoreStrings.NavigationNotAdded(
nameof(ImplicitManyToManyA), nameof(ImplicitManyToManyA.Bs), "List<ImplicitManyToManyB>"),
Assert.Throws<InvalidOperationException>(
() => base.Join_type_is_automatically_configured_by_convention()).Message);
}

public override void ForeignKeyAttribute_configures_the_properties()
{
// Many-to-many not configured by convention on Cosmos
// Cosmos many-to-many. Issue #23523.
Assert.Equal(
CoreStrings.NavigationNotAdded(
nameof(CategoryWithAttribute), nameof(CategoryWithAttribute.Products), "ICollection<ProductWithAttribute>"),
Assert.Throws<InvalidOperationException>(
() => base.ForeignKeyAttribute_configures_the_properties()).Message);
}

protected override TestModelBuilder CreateModelBuilder(Action<ModelConfigurationBuilder> configure = null)
Expand All @@ -505,11 +524,19 @@ public class CosmosGenericOwnedTypes : GenericOwnedTypes
public override void Deriving_from_owned_type_throws()
{
// On Cosmos the base type starts as owned
Assert.Contains(
"(No exception was thrown)",
Assert.Throws<ThrowsException>(
() => base.Deriving_from_owned_type_throws()).Message);
}

public override void Configuring_base_type_as_owned_throws()
{
// On Cosmos the base type starts as owned
Assert.Contains(
"(No exception was thrown)",
Assert.Throws<ThrowsException>(
() => base.Deriving_from_owned_type_throws()).Message);
}

[ConditionalFact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.SqlServer.Design.Internal;
using Microsoft.EntityFrameworkCore.SqlServer.Internal;
using Microsoft.EntityFrameworkCore.SqlServer.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -1075,23 +1076,28 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
skipBuild: true);
}

[ConditionalFact(Skip = "issue #26007")]
[ConditionalFact]
public void Temporal_table_works()
{
Test(
modelBuilder => modelBuilder.Entity(
"Customer", e =>
{
e.Property<int>("Id");
e.Property<string>("Name");
e.HasKey("Id");
e.ToTable(tb => tb.IsTemporal());
}),
new ModelCodeGenerationOptions { UseDataAnnotations = false },
code =>
{
AssertFileContents(
@"using System;
// Shadow properties. Issue #26007.
Assert.Equal(
SqlServerStrings.TemporalPeriodPropertyMustBeInShadowState("Customer", "PeriodStart"),
Assert.Throws<InvalidOperationException>(
() =>
Test(
modelBuilder => modelBuilder.Entity(
"Customer", e =>
{
e.Property<int>("Id");
e.Property<string>("Name");
e.HasKey("Id");
e.ToTable(tb => tb.IsTemporal());
}),
new ModelCodeGenerationOptions { UseDataAnnotations = false },
code =>
{
AssertFileContents(
@"using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
Expand All @@ -1115,7 +1121,9 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
#warning " + DesignStrings.SensitiveInformationWarning + @"
#warning "
+ DesignStrings.SensitiveInformationWarning
+ @"
optionsBuilder.UseSqlServer(""Initial Catalog=TestDatabase"");
}
}
Expand Down Expand Up @@ -1145,12 +1153,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
}
}
",
code.ContextFile);
},
model =>
{
// TODO
});
code.ContextFile);
},
model =>
{
// TODO
})).Message);
}

protected override void AddModelServices(IServiceCollection services)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Microsoft.EntityFrameworkCore.TestUtilities;
using Microsoft.Extensions.Logging;
using Xunit;
using Xunit.Sdk;

// ReSharper disable InconsistentNaming
namespace Microsoft.EntityFrameworkCore.Infrastructure
Expand Down Expand Up @@ -900,7 +901,7 @@ public virtual void Passes_for_shared_columns()
Validate(modelBuilder);
}

[ConditionalFact(Skip = "Issue #23144")]
[ConditionalFact]
public virtual void Detects_duplicate_foreignKey_names_within_hierarchy_on_different_tables()
{
var modelBuilder = CreateConventionalModelBuilder();
Expand All @@ -911,14 +912,18 @@ public virtual void Detects_duplicate_foreignKey_names_within_hierarchy_on_diffe
modelBuilder.Entity<Cat>().ToTable("Cats");
modelBuilder.Entity<Dog>().ToTable("Dogs");

VerifyError(
RelationalStrings.DuplicateForeignKeyTableMismatch(
"{'FriendId'}", nameof(Dog),
"{'FriendId'}", nameof(Cat),
"FK",
"Cats",
"Dogs"),
modelBuilder);
// Should throw. Issue #23144.
Assert.Contains(
"(No exception was thrown)",
Assert.Throws<ThrowsException>(
() => VerifyError(
RelationalStrings.DuplicateForeignKeyTableMismatch(
"{'FriendId'}", nameof(Dog),
"{'FriendId'}", nameof(Cat),
"FK",
"Cats",
"Dogs"),
modelBuilder)).Message);
}

[ConditionalFact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10330,7 +10330,7 @@ public void Rename_property_on_subtype_and_add_similar_to_base()
});
}

[ConditionalFact(Skip = "#15339")]
[ConditionalFact]
public void Owner_pk_properties_appear_before_owned_pk_which_preserves_annotations()
{
Execute(
Expand Down Expand Up @@ -10363,13 +10363,13 @@ public void Owner_pk_properties_appear_before_owned_pk_which_preserves_annotatio
Assert.Equal(50, c.MaxLength);
Assert.False(c.IsUnicode);
},
c => Assert.Equal("DisplayName", c.Name),
c =>
{
Assert.Equal("Created_Reason", c.Name);
Assert.Equal(255, c.MaxLength);
Assert.False(c.IsUnicode);
},
c => Assert.Equal("DisplayName", c.Name)
}
);
});
}
Expand Down
Loading

0 comments on commit 14dc6ce

Please sign in to comment.