mirror of
https://github.com/freedbygrace/WindowsNotifications.git
synced 2026-08-06 09:17:42 +00:00
Add PowerShell cmdlets and update project structure
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using WindowsNotifications;
|
||||
using WindowsNotifications.Models;
|
||||
|
||||
namespace WindowsNotifications.Tests
|
||||
@@ -8,203 +9,165 @@ namespace WindowsNotifications.Tests
|
||||
[TestFixture]
|
||||
public class NotificationManagerTests
|
||||
{
|
||||
[Test]
|
||||
public void Constructor_SetsDefaultDatabasePath()
|
||||
{
|
||||
// Act
|
||||
var manager = new SimpleNotificationManager();
|
||||
private string _testDbPath;
|
||||
private NotificationManager _manager;
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(manager.DatabasePath);
|
||||
Assert.IsTrue(manager.DatabasePath.Contains("WindowsNotifications"));
|
||||
Assert.IsTrue(manager.DatabasePath.EndsWith("notifications.db"));
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_testDbPath = Path.Combine(Path.GetTempPath(), string.Format("test_notifications_{0}.db", Guid.NewGuid()));
|
||||
_manager = new NotificationManager(_testDbPath);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Constructor_SetsCustomDatabasePath()
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
// Arrange
|
||||
string customPath = Path.Combine(Path.GetTempPath(), "custom.db");
|
||||
|
||||
// Act
|
||||
var manager = new SimpleNotificationManager(customPath);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(customPath, manager.DatabasePath);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ShowNotification_ValidatesOptions()
|
||||
{
|
||||
// Arrange
|
||||
var manager = new SimpleNotificationManager();
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<ArgumentNullException>(() => manager.ShowNotification(null));
|
||||
|
||||
var emptyOptions = new NotificationOptions();
|
||||
Assert.Throws<ArgumentException>(() => manager.ShowNotification(emptyOptions));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ShowNotification_ReturnsValidResult()
|
||||
{
|
||||
// Arrange
|
||||
var manager = new SimpleNotificationManager();
|
||||
var options = new NotificationOptions
|
||||
if (File.Exists(_testDbPath))
|
||||
{
|
||||
Title = "Test Title",
|
||||
Message = "Test Message"
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = manager.ShowNotification(options);
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual(options.Id, result.NotificationId);
|
||||
Assert.IsTrue(result.Displayed);
|
||||
Assert.IsNotNull(result.CreatedTime);
|
||||
try
|
||||
{
|
||||
File.Delete(_testDbPath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore errors
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ShowSimpleNotification_ReturnsValidResult()
|
||||
public void NotificationManager_Constructor_DefaultPath_IsCorrect()
|
||||
{
|
||||
// Arrange
|
||||
var manager = new SimpleNotificationManager();
|
||||
|
||||
// Act
|
||||
var result = manager.ShowSimpleNotification("Test Title", "Test Message");
|
||||
// Arrange & Act
|
||||
var manager = new NotificationManager();
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.NotificationId);
|
||||
Assert.IsTrue(result.Displayed);
|
||||
Assert.IsNotNull(result.CreatedTime);
|
||||
string dbPath = manager.GetDatabaseFilePath();
|
||||
Assert.IsNotNull(dbPath);
|
||||
Assert.IsTrue(dbPath.Contains("WindowsNotifications"));
|
||||
Assert.IsTrue(dbPath.EndsWith(".db"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ShowNotificationWithButtons_ReturnsValidResult()
|
||||
public void NotificationManager_Constructor_CustomPath_IsCorrect()
|
||||
{
|
||||
// Arrange
|
||||
var manager = new SimpleNotificationManager();
|
||||
|
||||
// Act
|
||||
var result = manager.ShowNotificationWithButtons("Test Title", "Test Message", "Button 1", "Button 2");
|
||||
// Arrange & Act
|
||||
var customPath = Path.Combine(Path.GetTempPath(), "custom_notifications.db");
|
||||
var manager = new NotificationManager(customPath);
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.NotificationId);
|
||||
Assert.IsTrue(result.Displayed);
|
||||
Assert.IsNotNull(result.CreatedTime);
|
||||
Assert.IsTrue(result.Activated);
|
||||
Assert.IsNotNull(result.ClickedButtonId);
|
||||
Assert.IsNotNull(result.ClickedButtonText);
|
||||
Assert.IsNotNull(result.ClickedButtonArgument);
|
||||
Assert.AreEqual(customPath, manager.GetDatabaseFilePath());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetDatabaseFilePath_ReturnsDatabasePath()
|
||||
public void NotificationManager_IsRunningAsSystem_ReturnsCorrectValue()
|
||||
{
|
||||
// Arrange
|
||||
string customPath = Path.Combine(Path.GetTempPath(), "custom.db");
|
||||
var manager = new SimpleNotificationManager(customPath);
|
||||
|
||||
// Act
|
||||
string path = manager.GetDatabaseFilePath();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(customPath, path);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsRunningAsSystem_ReturnsFalse()
|
||||
{
|
||||
// Arrange
|
||||
var manager = new SimpleNotificationManager();
|
||||
|
||||
// Act
|
||||
bool isSystem = manager.IsRunningAsSystem();
|
||||
// Arrange & Act
|
||||
bool isSystem = _manager.IsRunningAsSystem();
|
||||
|
||||
// Assert
|
||||
// This will be false in a test environment, but we're just testing the method returns a value
|
||||
Assert.IsFalse(isSystem);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetInteractiveUserSessions_ReturnsEmptyList()
|
||||
public void NotificationManager_GetInteractiveUserSessions_ReturnsNonNullList()
|
||||
{
|
||||
// Arrange
|
||||
var manager = new SimpleNotificationManager();
|
||||
|
||||
// Act
|
||||
var sessions = manager.GetInteractiveUserSessions();
|
||||
// Arrange & Act
|
||||
var sessions = _manager.GetInteractiveUserSessions();
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(sessions);
|
||||
Assert.AreEqual(0, sessions.Count);
|
||||
// We can't assert the count because it depends on the environment
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetNotificationResult_ReturnsNull()
|
||||
public void NotificationManager_ShowSimpleNotification_ReturnsResult()
|
||||
{
|
||||
// Arrange
|
||||
var manager = new SimpleNotificationManager();
|
||||
string title = "Test Title";
|
||||
string message = "Test Message";
|
||||
|
||||
// Act
|
||||
var result = manager.GetNotificationResult("test-id");
|
||||
var result = _manager.ShowSimpleNotification(title, message);
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.NotificationId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NotificationManager_ShowNotificationWithButtons_ReturnsResult()
|
||||
{
|
||||
// Arrange
|
||||
string title = "Test Title";
|
||||
string message = "Test Message";
|
||||
string[] buttons = new[] { "OK", "Cancel" };
|
||||
|
||||
// Act
|
||||
var result = _manager.ShowNotificationWithButtons(title, message, buttons);
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.NotificationId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NotificationManager_ShowRebootNotification_ReturnsResult()
|
||||
{
|
||||
// Arrange
|
||||
string title = "Test Title";
|
||||
string message = "Test Message";
|
||||
|
||||
// Act
|
||||
var result = _manager.ShowRebootNotification(title, message);
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.NotificationId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NotificationManager_GetNotificationResult_ReturnsNullForNonExistentId()
|
||||
{
|
||||
// Arrange
|
||||
string nonExistentId = Guid.NewGuid().ToString();
|
||||
|
||||
// Act
|
||||
var result = _manager.GetNotificationResult(nonExistentId);
|
||||
|
||||
// Assert
|
||||
Assert.IsNull(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WaitForNotification_ReturnsNull()
|
||||
public void NotificationManager_GetAllNotificationResults_ReturnsNonNullList()
|
||||
{
|
||||
// Arrange
|
||||
var manager = new SimpleNotificationManager();
|
||||
|
||||
// Act
|
||||
var result = manager.WaitForNotification("test-id", 100);
|
||||
|
||||
// Assert
|
||||
Assert.IsNull(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllNotificationResults_ReturnsEmptyList()
|
||||
{
|
||||
// Arrange
|
||||
var manager = new SimpleNotificationManager();
|
||||
|
||||
// Act
|
||||
var results = manager.GetAllNotificationResults();
|
||||
// Arrange & Act
|
||||
var results = _manager.GetAllNotificationResults();
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(results);
|
||||
Assert.AreEqual(0, results.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeleteNotificationResult_ReturnsTrue()
|
||||
public void NotificationManager_DeleteNotificationResult_ReturnsFalseForNonExistentId()
|
||||
{
|
||||
// Arrange
|
||||
var manager = new SimpleNotificationManager();
|
||||
string nonExistentId = Guid.NewGuid().ToString();
|
||||
|
||||
// Act
|
||||
bool result = manager.DeleteNotificationResult("test-id");
|
||||
bool result = _manager.DeleteNotificationResult(nonExistentId);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(result);
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeleteAllNotificationResults_ReturnsTrue()
|
||||
public void NotificationManager_DeleteAllNotificationResults_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
var manager = new SimpleNotificationManager();
|
||||
|
||||
// Act
|
||||
bool result = manager.DeleteAllNotificationResults();
|
||||
// Arrange & Act
|
||||
bool result = _manager.DeleteAllNotificationResults();
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(result);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,82 +8,84 @@ namespace WindowsNotifications.Tests
|
||||
public class NotificationResultTests
|
||||
{
|
||||
[Test]
|
||||
public void Constructor_SetsNotificationId()
|
||||
public void NotificationResult_DefaultValues_AreCorrect()
|
||||
{
|
||||
// Arrange
|
||||
string notificationId = "test-id";
|
||||
|
||||
// Act
|
||||
var result = new NotificationResult(notificationId);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(notificationId, result.NotificationId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Constructor_SetsDefaultValues()
|
||||
{
|
||||
// Arrange
|
||||
string notificationId = "test-id";
|
||||
|
||||
// Act
|
||||
var result = new NotificationResult(notificationId);
|
||||
// Arrange & Act
|
||||
var result = new NotificationResult();
|
||||
|
||||
// Assert
|
||||
Assert.IsNull(result.NotificationId);
|
||||
Assert.IsFalse(result.Displayed);
|
||||
Assert.IsFalse(result.Activated);
|
||||
Assert.IsFalse(result.Dismissed);
|
||||
Assert.IsNull(result.ClickedButtonId);
|
||||
Assert.IsNull(result.ClickedButtonText);
|
||||
Assert.IsNull(result.ClickedButtonArgument);
|
||||
Assert.IsNull(result.ErrorMessage);
|
||||
Assert.IsTrue((DateTime.Now - result.CreatedTime).TotalSeconds < 1);
|
||||
Assert.IsNull(result.InteractionTime);
|
||||
// CreatedTime should be close to now
|
||||
Assert.Less((DateTime.Now - result.CreatedTime).TotalSeconds, 5);
|
||||
Assert.IsNull(result.ErrorMessage);
|
||||
Assert.IsNull(result.ErrorCode);
|
||||
Assert.IsFalse(result.Deferred);
|
||||
Assert.IsNull(result.DeferredUntil);
|
||||
Assert.IsNull(result.DeferralReason);
|
||||
Assert.IsNull(result.DismissalReason);
|
||||
Assert.IsNull(result.SystemAction);
|
||||
Assert.IsFalse(result.DeadlineReached);
|
||||
Assert.IsNull(result.DeadlineReachedTime);
|
||||
Assert.IsNull(result.DeadlineAction);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Error_CreatesErrorResult()
|
||||
public void NotificationResult_SetProperties_ValuesAreCorrect()
|
||||
{
|
||||
// Arrange
|
||||
string notificationId = "test-id";
|
||||
string errorMessage = "Test error message";
|
||||
|
||||
// Act
|
||||
var result = NotificationResult.Error(notificationId, errorMessage);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(notificationId, result.NotificationId);
|
||||
Assert.AreEqual(errorMessage, result.ErrorMessage);
|
||||
Assert.IsFalse(result.Displayed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Properties_CanBeSet()
|
||||
{
|
||||
// Arrange
|
||||
var result = new NotificationResult("test-id");
|
||||
DateTime interactionTime = DateTime.Now;
|
||||
var result = new NotificationResult();
|
||||
var createdTime = DateTime.Now.AddMinutes(-5);
|
||||
var interactionTime = DateTime.Now.AddMinutes(-2);
|
||||
var deferredUntil = DateTime.Now.AddHours(1);
|
||||
var deadlineReachedTime = DateTime.Now.AddMinutes(-1);
|
||||
|
||||
// Act
|
||||
result.NotificationId = "test-id";
|
||||
result.Displayed = true;
|
||||
result.Activated = true;
|
||||
result.Dismissed = true;
|
||||
result.ClickedButtonId = "button-id";
|
||||
result.ClickedButtonText = "Button Text";
|
||||
result.ClickedButtonArgument = "button-arg";
|
||||
result.ErrorMessage = "Error message";
|
||||
result.ClickedButtonId = "button1";
|
||||
result.ClickedButtonText = "OK";
|
||||
result.ClickedButtonArgument = "ok";
|
||||
result.CreatedTime = createdTime;
|
||||
result.InteractionTime = interactionTime;
|
||||
result.ErrorMessage = "Test error";
|
||||
result.ErrorCode = "E001";
|
||||
result.Deferred = true;
|
||||
result.DeferredUntil = deferredUntil;
|
||||
result.DeferralReason = "User requested";
|
||||
result.DismissalReason = "User dismissed";
|
||||
result.SystemAction = "snooze";
|
||||
result.DeadlineReached = true;
|
||||
result.DeadlineReachedTime = deadlineReachedTime;
|
||||
result.DeadlineAction = "restart";
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("test-id", result.NotificationId);
|
||||
Assert.IsTrue(result.Displayed);
|
||||
Assert.IsTrue(result.Activated);
|
||||
Assert.IsTrue(result.Dismissed);
|
||||
Assert.AreEqual("button-id", result.ClickedButtonId);
|
||||
Assert.AreEqual("Button Text", result.ClickedButtonText);
|
||||
Assert.AreEqual("button-arg", result.ClickedButtonArgument);
|
||||
Assert.AreEqual("Error message", result.ErrorMessage);
|
||||
Assert.AreEqual("button1", result.ClickedButtonId);
|
||||
Assert.AreEqual("OK", result.ClickedButtonText);
|
||||
Assert.AreEqual("ok", result.ClickedButtonArgument);
|
||||
Assert.AreEqual(createdTime, result.CreatedTime);
|
||||
Assert.AreEqual(interactionTime, result.InteractionTime);
|
||||
Assert.AreEqual("Test error", result.ErrorMessage);
|
||||
Assert.AreEqual("E001", result.ErrorCode);
|
||||
Assert.IsTrue(result.Deferred);
|
||||
Assert.AreEqual(deferredUntil, result.DeferredUntil);
|
||||
Assert.AreEqual("User requested", result.DeferralReason);
|
||||
Assert.AreEqual("User dismissed", result.DismissalReason);
|
||||
Assert.AreEqual("snooze", result.SystemAction);
|
||||
Assert.IsTrue(result.DeadlineReached);
|
||||
Assert.AreEqual(deadlineReachedTime, result.DeadlineReachedTime);
|
||||
Assert.AreEqual("restart", result.DeadlineAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("WindowsNotifications.Tests")]
|
||||
[assembly: AssemblyDescription("Tests for the Windows Notifications library")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("WindowsNotifications.Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("b1c2d3e4-f5g6-47a8-b9c0-d1e2f3a4b5c6")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,18 @@
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace WindowsNotifications.Tests
|
||||
{
|
||||
public class Tests
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test1()
|
||||
{
|
||||
Assert.Pass();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,73 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\NUnit.3.12.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" />
|
||||
<Import Project="..\packages\NUnit3TestAdapter.3.16.1\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.16.1\build\net35\NUnit3TestAdapter.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{B1C2D3E4-F5G6-47A8-B9C0-D1E2F3A4B5C6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>WindowsNotifications.Tests</RootNamespace>
|
||||
<AssemblyName>WindowsNotifications.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||
<Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WindowsNotifications\SimpleWindowsNotifications.csproj" />
|
||||
<Compile Include="NotificationManagerTests.cs" />
|
||||
<Compile Include="NotificationOptionsTests.cs" />
|
||||
<Compile Include="NotificationResultTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WindowsNotifications\WindowsNotifications.csproj">
|
||||
<Project>{A1B2C3D4-E5F6-47A8-B9C0-D1E2F3A4B5C6}</Project>
|
||||
<Name>WindowsNotifications</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.12.0\build\NUnit.props'))" />
|
||||
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.16.1\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.16.1\build\net35\NUnit3TestAdapter.props'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="3.12.0" targetFramework="net472" />
|
||||
<package id="NUnit3TestAdapter" version="3.16.1" targetFramework="net472" developmentDependency="true" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user