- Added ComplianceNFs.Infrastructure.Tests project to the solution. - Implemented unit tests for AccessDbRepository, ArchivingService, AttachmentRepository, InvoiceIngestionService, MailListener, MonitorViewModel, and Worker. - Enhanced existing tests with additional assertions and mock setups. - Updated TODOs and roadmap documentation to reflect changes in service implementations and testing coverage. - Modified ComplianceNFs.sln to include new test project and adjust solution properties.
57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Windows.Input;
|
|
using ComplianceNFs.Core.Application;
|
|
using ComplianceNFs.Core.Entities;
|
|
|
|
namespace ComplianceNFs.Monitor
|
|
{
|
|
public class MonitorViewModel : INotifyPropertyChanged
|
|
{
|
|
public ObservableCollection<EnergyInvoice> RecentInvoices { get; } = [];
|
|
public ICommand ForceScanCommand { get; }
|
|
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
public IInvoiceStatusStream? StatusStream { get; }
|
|
|
|
public MonitorViewModel(IInvoiceStatusStream statusStream)
|
|
{
|
|
StatusStream = statusStream;
|
|
foreach (var inv in statusStream.GetRecent(100))
|
|
RecentInvoices.Add(inv);
|
|
statusStream.StatusUpdated += OnStatusUpdated;
|
|
ForceScanCommand = new RelayCommand(_ => ForceScan());
|
|
}
|
|
|
|
private void OnStatusUpdated(EnergyInvoice invoice)
|
|
{
|
|
RecentInvoices.Add(invoice);
|
|
OnPropertyChanged(nameof(RecentInvoices));
|
|
}
|
|
|
|
private static void ForceScan()
|
|
{
|
|
// TODO: Call service to force ingestion cycle
|
|
}
|
|
|
|
protected void OnPropertyChanged([CallerMemberName] string? name = null)
|
|
{
|
|
if (name != null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); }
|
|
}
|
|
}
|
|
|
|
public class RelayCommand(Action<object> execute, Func<object, bool>? canExecute = null) : ICommand
|
|
{
|
|
public bool CanExecute(object? parameter) => parameter != null && (canExecute == null || canExecute(parameter));
|
|
public void Execute(object? parameter)
|
|
{
|
|
if (parameter != null) { execute(parameter); }
|
|
}
|
|
|
|
public event EventHandler? CanExecuteChanged { add { } remove { } }
|
|
}
|
|
}
|