mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 11:14:45 +00:00
Add mock constructors to allow designer to instantiate viewmodels.
This commit is contained in:
@@ -49,6 +49,41 @@ public class EditDatViewModel : ViewModelBase
|
||||
string _name;
|
||||
string _version;
|
||||
|
||||
// Mock
|
||||
public EditDatViewModel()
|
||||
{
|
||||
var romSet = new RomSetModel
|
||||
{
|
||||
Author = "Author",
|
||||
Comment = "Comment",
|
||||
Category = "Category",
|
||||
Date = "Date",
|
||||
Description = "Description",
|
||||
Homepage = "http://example.com",
|
||||
Name = "Name",
|
||||
Version = "Version",
|
||||
Filename = "Filename.dat",
|
||||
Sha384 = "MOCKEDSHA384HASH",
|
||||
TotalMachines = 100,
|
||||
CompleteMachines = 80,
|
||||
IncompleteMachines = 20,
|
||||
TotalRoms = 1000,
|
||||
HaveRoms = 800,
|
||||
MissRoms = 200,
|
||||
Id = 1
|
||||
};
|
||||
|
||||
_romSet = romSet;
|
||||
_name = romSet.Name;
|
||||
_version = romSet.Version;
|
||||
_author = romSet.Author;
|
||||
_comment = romSet.Comment;
|
||||
_category = romSet.Category;
|
||||
_date = romSet.Date;
|
||||
_description = romSet.Description;
|
||||
_homepage = romSet.Homepage;
|
||||
}
|
||||
|
||||
public EditDatViewModel(EditDat view, RomSetModel romSet)
|
||||
{
|
||||
_view = view;
|
||||
|
||||
@@ -49,6 +49,9 @@ public sealed class ExportDatViewModel : ViewModelBase
|
||||
bool _progressVisible;
|
||||
string _statusMessage;
|
||||
|
||||
// Mock
|
||||
public ExportDatViewModel() {}
|
||||
|
||||
public ExportDatViewModel(ExportDat view, string datHash, string outPath)
|
||||
{
|
||||
_view = view;
|
||||
|
||||
@@ -58,6 +58,14 @@ public sealed class ExportRomsViewModel : ViewModelBase
|
||||
string _status3Message;
|
||||
string _statusMessage;
|
||||
|
||||
// Mock
|
||||
public ExportRomsViewModel()
|
||||
{
|
||||
#pragma warning disable PH2080
|
||||
FolderPath = "C:\\ExportedRoms";
|
||||
#pragma warning restore PH2080
|
||||
}
|
||||
|
||||
public ExportRomsViewModel(ExportRoms view, string folderPath, long romSetId)
|
||||
{
|
||||
_view = view;
|
||||
|
||||
@@ -64,6 +64,14 @@ public sealed class ImportDatFolderViewModel : ViewModelBase
|
||||
string _status2Message;
|
||||
string _statusMessage;
|
||||
|
||||
// Mock
|
||||
public ImportDatFolderViewModel()
|
||||
{
|
||||
#pragma warning disable PH2080
|
||||
FolderPath = "C:\\ROMs";
|
||||
#pragma warning restore PH2080
|
||||
}
|
||||
|
||||
public ImportDatFolderViewModel(ImportDatFolder view, string folderPath)
|
||||
{
|
||||
_view = view;
|
||||
|
||||
@@ -48,6 +48,9 @@ public sealed class ImportDatViewModel : ViewModelBase
|
||||
bool _progressVisible;
|
||||
string _statusMessage;
|
||||
|
||||
// Mock
|
||||
public ImportDatViewModel() {}
|
||||
|
||||
public ImportDatViewModel(ImportDat view, string datPath)
|
||||
{
|
||||
_view = view;
|
||||
|
||||
@@ -61,6 +61,14 @@ public sealed class ImportRomFolderViewModel : ViewModelBase
|
||||
string _status2Message;
|
||||
string _statusMessage;
|
||||
|
||||
// Mock
|
||||
public ImportRomFolderViewModel()
|
||||
{
|
||||
#pragma warning disable PH2080
|
||||
FolderPath = "C:\\ROMs";
|
||||
#pragma warning restore PH2080
|
||||
}
|
||||
|
||||
public ImportRomFolderViewModel(ImportRomFolder view, string folderPath)
|
||||
{
|
||||
_view = view;
|
||||
|
||||
@@ -52,6 +52,9 @@ public class MainWindowViewModel : ViewModelBase
|
||||
RomSetModel _selectedRomSet;
|
||||
Vfs _vfs;
|
||||
|
||||
// Mock
|
||||
public MainWindowViewModel() {}
|
||||
|
||||
public MainWindowViewModel(MainWindow view, List<RomSetModel> romSets)
|
||||
{
|
||||
_view = view;
|
||||
|
||||
@@ -35,9 +35,20 @@ using RomRepoMgr.Views;
|
||||
|
||||
namespace RomRepoMgr.ViewModels;
|
||||
|
||||
public sealed class RemoveDatViewModel(RemoveDat view, long romSetId) : ViewModelBase
|
||||
public sealed class RemoveDatViewModel : ViewModelBase
|
||||
{
|
||||
string _statusMessage;
|
||||
readonly long _romSetId;
|
||||
readonly RemoveDat _view;
|
||||
string _statusMessage;
|
||||
|
||||
// Mock
|
||||
public RemoveDatViewModel() {}
|
||||
|
||||
public RemoveDatViewModel(RemoveDat view, long romSetId)
|
||||
{
|
||||
_view = view;
|
||||
_romSetId = romSetId;
|
||||
}
|
||||
|
||||
public string StatusMessage
|
||||
{
|
||||
@@ -53,7 +64,7 @@ public sealed class RemoveDatViewModel(RemoveDat view, long romSetId) : ViewMode
|
||||
|
||||
Dispatcher.UIThread.Post(() => StatusMessage = Localization.RetrievingRomSetFromDatabase);
|
||||
|
||||
RomSet romSet = ctx.RomSets.Find(romSetId);
|
||||
RomSet romSet = ctx.RomSets.Find(_romSetId);
|
||||
|
||||
if(romSet == null) return;
|
||||
|
||||
@@ -93,7 +104,7 @@ public sealed class RemoveDatViewModel(RemoveDat view, long romSetId) : ViewMode
|
||||
|
||||
if(File.Exists(compressedDatPath)) File.Delete(compressedDatPath);
|
||||
|
||||
Dispatcher.UIThread.Post(view.Close);
|
||||
Dispatcher.UIThread.Post(_view.Close);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,9 @@ public sealed class SettingsViewModel : ViewModelBase
|
||||
string _unArPath;
|
||||
string _unArVersion;
|
||||
|
||||
// Mock
|
||||
public SettingsViewModel() {}
|
||||
|
||||
public SettingsViewModel(SettingsDialog view)
|
||||
{
|
||||
_view = view;
|
||||
|
||||
@@ -51,6 +51,9 @@ public sealed class UpdateStatsViewModel : ViewModelBase
|
||||
RomSetModel _selectedRomSet;
|
||||
string _statusMessage;
|
||||
|
||||
// Mock
|
||||
public UpdateStatsViewModel() {}
|
||||
|
||||
public UpdateStatsViewModel(UpdateStats view)
|
||||
{
|
||||
_view = view;
|
||||
|
||||
Reference in New Issue
Block a user