public async Task New_array_with_heterogeneous_columns_throws(bool async) { // Note that arrays of objects are treated specially by EF Core, so they're fine. // The below checks Bytea and ByteArray, which are the same CLR type (byte[]) but mapped to different PG types // (bytea and smallint[]) using var context = CreateContext(); var exception = async ? await Assert.ThrowsAsync <InvalidOperationException>( () => context.Set <ArrayEntity>().Select(e => new[] { e.Bytea, e.ByteArray }).ToListAsync()) : Assert.Throws <InvalidOperationException>( () => context.Set <ArrayEntity>().Select(e => new[] { e.Bytea, e.ByteArray }).ToList()); Assert.Equal(NpgsqlStrings.HeterogeneousTypesInNewArray("bytea", "smallint[]"), exception.Message); }
public void Throws_setting_sequence_generation_for_invalid_type() { var propertyBuilder = CreateBuilder() .Entity(typeof(Splot)) .Property(typeof(string), "Name"); Assert.Equal( NpgsqlStrings.SequenceBadType("Name", nameof(Splot), "string"), Assert.Throws <ArgumentException>( () => propertyBuilder.HasValueGenerationStrategy(NpgsqlValueGenerationStrategy.SequenceHiLo)).Message); Assert.Equal( NpgsqlStrings.SequenceBadType("Name", nameof(Splot), "string"), Assert.Throws <ArgumentException>( () => new PropertyBuilder((IMutableProperty)propertyBuilder.Metadata).UseHiLo()).Message); }