using ZB.MOM.WW.ScadaBridge.Commons.Entities.Notifications;
namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Entities;
///
/// Commons-NNN: locks the construction invariants
/// (exactly one contact field populated per channel; non-blank name on every path).
///
public class NotificationRecipientTests
{
[Fact]
public void ForEmail_SetsEmail_LeavesPhoneNull()
{
var r = NotificationRecipient.ForEmail("Jane", "jane@example.com");
Assert.Equal("Jane", r.Name);
Assert.Equal("jane@example.com", r.EmailAddress);
Assert.Null(r.PhoneNumber);
}
[Fact]
public void ForSms_SetsPhone_LeavesEmailNull()
{
var r = NotificationRecipient.ForSms("Jane", "+15551234567");
Assert.Equal("Jane", r.Name);
Assert.Equal("+15551234567", r.PhoneNumber);
Assert.Null(r.EmailAddress);
}
[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void ForEmail_BlankName_Throws(string? name)
=> Assert.Throws(() => NotificationRecipient.ForEmail(name!, "jane@example.com"));
[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void ForSms_BlankName_Throws(string? name)
=> Assert.Throws(() => NotificationRecipient.ForSms(name!, "+15551234567"));
[Fact]
public void ForEmail_NullEmail_Throws()
=> Assert.Throws(() => NotificationRecipient.ForEmail("Jane", null!));
[Fact]
public void ForSms_NullPhone_Throws()
=> Assert.Throws(() => NotificationRecipient.ForSms("Jane", null!));
[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void PublicCtor_BlankName_Throws(string? name)
=> Assert.Throws(() => new NotificationRecipient(name!, "jane@example.com"));
[Fact]
public void PublicCtor_NullEmail_Throws()
=> Assert.Throws(() => new NotificationRecipient("Jane", null!));
}