mirror of
https://github.com/freedbygrace/WindowsNotifications.git
synced 2026-08-05 08:47:42 +00:00
Add PowerShell cmdlets and update project structure
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using WindowsNotifications.Models;
|
||||
|
||||
namespace WindowsNotifications.Tests
|
||||
@@ -9,36 +8,41 @@ namespace WindowsNotifications.Tests
|
||||
public class NotificationOptionsTests
|
||||
{
|
||||
[Test]
|
||||
public void Constructor_SetsDefaultValues()
|
||||
public void NotificationOptions_DefaultValues_AreCorrect()
|
||||
{
|
||||
// Act
|
||||
// Arrange & Act
|
||||
var options = new NotificationOptions();
|
||||
|
||||
// Assert
|
||||
Assert.IsNull(options.Title);
|
||||
Assert.IsNull(options.Message);
|
||||
Assert.IsNull(options.LogoImagePath);
|
||||
Assert.IsNull(options.HeroImagePath);
|
||||
Assert.IsNull(options.Attribution);
|
||||
Assert.AreEqual(0, options.TimeoutInSeconds);
|
||||
Assert.IsNotNull(options.Buttons);
|
||||
Assert.AreEqual(0, options.Buttons.Count);
|
||||
Assert.IsFalse(options.Async);
|
||||
Assert.IsNotNull(options.Id);
|
||||
Assert.IsTrue(Guid.TryParse(options.Id, out _));
|
||||
Assert.IsNull(options.Tag);
|
||||
Assert.IsNull(options.Group);
|
||||
Assert.IsFalse(options.PersistState);
|
||||
Assert.IsTrue(options.EnableLogging);
|
||||
Assert.IsTrue(options.PersistState);
|
||||
Assert.AreEqual(60, options.ReminderTimeInMinutes);
|
||||
Assert.IsFalse(options.ShowReminder);
|
||||
Assert.IsFalse(options.ShowCountdown);
|
||||
Assert.IsFalse(options.EnableLogging);
|
||||
Assert.IsNull(options.LogAction);
|
||||
Assert.IsNotNull(options.Buttons);
|
||||
Assert.AreEqual(0, options.Buttons.Count);
|
||||
Assert.IsNull(options.OnActivated);
|
||||
Assert.IsNull(options.OnTimeout);
|
||||
Assert.IsNull(options.OnError);
|
||||
Assert.IsNull(options.DeadlineTime);
|
||||
Assert.IsNull(options.DeadlineAction);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Properties_CanBeSet()
|
||||
public void NotificationOptions_SetProperties_ValuesAreCorrect()
|
||||
{
|
||||
// Arrange
|
||||
var options = new NotificationOptions();
|
||||
Action<string> logAction = (log) => { };
|
||||
var button = new NotificationButton("Test", "test");
|
||||
var deferralOptions = new DeferralOptions();
|
||||
var deadlineAction = DeadlineAction.ExecuteCommand("test");
|
||||
var deadlineTime = DateTime.Now.AddHours(1);
|
||||
Action<string> logAction = (s) => { };
|
||||
Action<NotificationResult> resultAction = (r) => { };
|
||||
|
||||
// Act
|
||||
options.Title = "Test Title";
|
||||
@@ -47,13 +51,23 @@ namespace WindowsNotifications.Tests
|
||||
options.HeroImagePath = "hero.png";
|
||||
options.Attribution = "Test Attribution";
|
||||
options.TimeoutInSeconds = 30;
|
||||
options.Buttons.Add(button);
|
||||
options.Async = true;
|
||||
options.Id = "custom-id";
|
||||
options.Id = "test-id";
|
||||
options.Tag = "test-tag";
|
||||
options.Group = "test-group";
|
||||
options.PersistState = true;
|
||||
options.EnableLogging = false;
|
||||
options.DeferralOptions = deferralOptions;
|
||||
options.ShowReminder = true;
|
||||
options.ReminderTimeInMinutes = 15;
|
||||
options.PersistState = false;
|
||||
options.EnableLogging = true;
|
||||
options.LogAction = logAction;
|
||||
options.OnActivated = resultAction;
|
||||
options.OnTimeout = resultAction;
|
||||
options.OnError = resultAction;
|
||||
options.DeadlineTime = deadlineTime;
|
||||
options.DeadlineAction = deadlineAction;
|
||||
options.ShowCountdown = true;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Test Title", options.Title);
|
||||
@@ -62,91 +76,24 @@ namespace WindowsNotifications.Tests
|
||||
Assert.AreEqual("hero.png", options.HeroImagePath);
|
||||
Assert.AreEqual("Test Attribution", options.Attribution);
|
||||
Assert.AreEqual(30, options.TimeoutInSeconds);
|
||||
Assert.AreEqual(1, options.Buttons.Count);
|
||||
Assert.AreEqual(button, options.Buttons[0]);
|
||||
Assert.IsTrue(options.Async);
|
||||
Assert.AreEqual("custom-id", options.Id);
|
||||
Assert.AreEqual("test-id", options.Id);
|
||||
Assert.AreEqual("test-tag", options.Tag);
|
||||
Assert.AreEqual("test-group", options.Group);
|
||||
Assert.IsTrue(options.PersistState);
|
||||
Assert.IsFalse(options.EnableLogging);
|
||||
Assert.AreEqual(deferralOptions, options.DeferralOptions);
|
||||
Assert.IsTrue(options.ShowReminder);
|
||||
Assert.AreEqual(15, options.ReminderTimeInMinutes);
|
||||
Assert.IsFalse(options.PersistState);
|
||||
Assert.IsTrue(options.EnableLogging);
|
||||
Assert.AreEqual(logAction, options.LogAction);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Buttons_CanBeAdded()
|
||||
{
|
||||
// Arrange
|
||||
var options = new NotificationOptions();
|
||||
var button1 = new NotificationButton("Button 1");
|
||||
var button2 = new NotificationButton("Button 2", "custom-id", "custom-arg");
|
||||
|
||||
// Act
|
||||
options.Buttons.Add(button1);
|
||||
options.Buttons.Add(button2);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(2, options.Buttons.Count);
|
||||
Assert.AreEqual("Button 1", options.Buttons[0].Text);
|
||||
Assert.AreEqual("Button 2", options.Buttons[1].Text);
|
||||
Assert.AreEqual("custom-id", options.Buttons[1].Id);
|
||||
Assert.AreEqual("custom-arg", options.Buttons[1].Argument);
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
public class NotificationButtonTests
|
||||
{
|
||||
[Test]
|
||||
public void Constructor_SetsText()
|
||||
{
|
||||
// Arrange & Act
|
||||
var button = new NotificationButton("Button Text");
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Button Text", button.Text);
|
||||
Assert.IsNotNull(button.Id);
|
||||
Assert.IsTrue(Guid.TryParse(button.Id, out _));
|
||||
Assert.AreEqual(button.Id, button.Argument);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Constructor_SetsCustomId()
|
||||
{
|
||||
// Arrange & Act
|
||||
var button = new NotificationButton("Button Text", "custom-id");
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Button Text", button.Text);
|
||||
Assert.AreEqual("custom-id", button.Id);
|
||||
Assert.AreEqual("custom-id", button.Argument);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Constructor_SetsCustomArgument()
|
||||
{
|
||||
// Arrange & Act
|
||||
var button = new NotificationButton("Button Text", "custom-id", "custom-arg");
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Button Text", button.Text);
|
||||
Assert.AreEqual("custom-id", button.Id);
|
||||
Assert.AreEqual("custom-arg", button.Argument);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Properties_CanBeSet()
|
||||
{
|
||||
// Arrange
|
||||
var button = new NotificationButton("Initial Text");
|
||||
|
||||
// Act
|
||||
button.Text = "Updated Text";
|
||||
button.Id = "updated-id";
|
||||
button.Argument = "updated-arg";
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Updated Text", button.Text);
|
||||
Assert.AreEqual("updated-id", button.Id);
|
||||
Assert.AreEqual("updated-arg", button.Argument);
|
||||
Assert.AreEqual(resultAction, options.OnActivated);
|
||||
Assert.AreEqual(resultAction, options.OnTimeout);
|
||||
Assert.AreEqual(resultAction, options.OnError);
|
||||
Assert.AreEqual(deadlineTime, options.DeadlineTime);
|
||||
Assert.AreEqual(deadlineAction, options.DeadlineAction);
|
||||
Assert.IsTrue(options.ShowCountdown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user