Removed database status in favor of much cleaner code

Implemented (but deactivated) anti corruption mechanism
WIP detect changes and save them if opening another database
This commit is contained in:
BONNEVILLE Geoffroy
2018-01-08 18:52:03 +01:00
parent 4a3f36d38b
commit a19519fa73
17 changed files with 220 additions and 101 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using ModernKeePass.Interfaces;
using ModernKeePass.ViewModels;
using ModernKeePassLib;
@@ -10,6 +11,11 @@ namespace ModernKeePassApp.Test.Mock
{
public class DatabaseServiceMock : IDatabase
{
private bool _isOpen;
private bool _isFileOpen;
private bool _isClosed;
public PwCompressionAlgorithm CompressionAlgorithm { get; set; }
public StorageFile DatabaseFile { get; set; }
@@ -18,6 +24,21 @@ namespace ModernKeePassApp.Test.Mock
public KdfParameters KeyDerivation { get; set; }
public bool IsOpen
{
get { return _isOpen; }
}
public bool IsFileOpen
{
get { return _isFileOpen; }
}
public bool IsClosed
{
get { return _isClosed; }
}
public string Name => "MockDatabase";
public GroupVm RecycleBin { get; set; }
@@ -25,17 +46,19 @@ namespace ModernKeePassApp.Test.Mock
public bool RecycleBinEnabled { get; set; }
public GroupVm RootGroup { get; set; }
public int Status { get; set; }
public void AddDeletedItem(PwUuid id)
{
throw new NotImplementedException();
}
public void Close()
public Task Close()
{
Status = 0;
return Task.Run(() =>
{
_isClosed = true;
_isOpen = false;
});
}
public void CreateRecycleBin()
@@ -43,9 +66,13 @@ namespace ModernKeePassApp.Test.Mock
throw new NotImplementedException();
}
public void Open(CompositeKey key, bool createNew)
public Task Open(CompositeKey key, bool createNew)
{
Status = 2;
return Task.Run(() =>
{
_isOpen = true;
_isClosed = false;
});
}
public void Save()
@@ -57,7 +84,7 @@ namespace ModernKeePassApp.Test.Mock
{
throw new NotImplementedException();
}
public void UpdateCompositeKey(CompositeKey key)
{
throw new NotImplementedException();