feat(sql-adminui): Postgres + Oracle in the provider dropdown; docs
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Forms;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.Sql;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.Sql.Contracts;
|
||||
|
||||
@@ -86,4 +87,47 @@ public sealed class SqlDriverFormContractTests
|
||||
json.ShouldContain("\"SqlServer\"");
|
||||
JsonSerializer.Deserialize<SqlDriverConfigDto>(json, FormOptions)!.Provider.ShouldBe(SqlProvider.SqlServer);
|
||||
}
|
||||
|
||||
// ---- the multi-provider dropdown: every offered option survives the form model's own round-trip ----
|
||||
|
||||
/// <summary>
|
||||
/// The dropdown offers SqlServer + Postgres + Oracle, so each must survive
|
||||
/// <c>FormModel.ToDto()</c> → JSON → <c>FormModel.FromDto()</c> as a NAME string. The razor markup
|
||||
/// itself is not reachable (no bUnit), so this pins the model half of the change: a provider the
|
||||
/// dropdown can select but the form model cannot carry back would silently reset to SqlServer on
|
||||
/// the next modal open.
|
||||
/// </summary>
|
||||
[Theory]
|
||||
[InlineData(SqlProvider.SqlServer, "SqlServer")]
|
||||
[InlineData(SqlProvider.Postgres, "Postgres")]
|
||||
[InlineData(SqlProvider.Oracle, "Oracle")]
|
||||
public void Every_dropdown_provider_round_trips_through_the_form_model(SqlProvider provider, string name)
|
||||
{
|
||||
var form = new SqlDriverForm.FormModel { Provider = provider, ConnectionStringRef = "MesStaging" };
|
||||
|
||||
var json = JsonSerializer.Serialize(form.ToDto(), FormOptions);
|
||||
|
||||
json.ShouldContain($"\"provider\":\"{name}\"");
|
||||
json.ShouldNotContain($"\"provider\":{(int)provider}"); // never an ordinal — that faults the factory read
|
||||
var reloaded = SqlDriverForm.FormModel.FromDto(
|
||||
JsonSerializer.Deserialize<SqlDriverConfigDto>(json, FormOptions)!);
|
||||
reloaded.Provider.ShouldBe(provider);
|
||||
reloaded.ConnectionStringRef.ShouldBe("MesStaging");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MySql and Odbc stay reserved-and-rejected (design §2), so the dropdown deliberately does not offer
|
||||
/// them. Nothing in the form model blocks the value — this records the intent so a later "the enum has
|
||||
/// five members, the dropdown should too" edit has to argue with a test.
|
||||
/// </summary>
|
||||
[Theory]
|
||||
[InlineData(SqlProvider.MySql)]
|
||||
[InlineData(SqlProvider.Odbc)]
|
||||
public void Reserved_providers_are_not_offered_but_still_serialize_by_name(SqlProvider reserved)
|
||||
{
|
||||
var json = JsonSerializer.Serialize(
|
||||
new SqlDriverForm.FormModel { Provider = reserved, ConnectionStringRef = "R" }.ToDto(), FormOptions);
|
||||
|
||||
json.ShouldContain($"\"provider\":\"{reserved}\"");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user