More refactoring

Added first simple unit test
This commit is contained in:
Philipp Crocoll
2013-06-18 21:12:34 +02:00
parent 8b08baa51a
commit 533c6f207e
23 changed files with 188 additions and 50 deletions

View File

@@ -15,21 +15,14 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll.
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using KeePassLib;
namespace keepass2android
{
/// <summary>
/// EqualityComparer implementation to compare PwGroups based on their Id
/// </summary>
class PwGroupEqualityFromIdComparer: IEqualityComparer<PwGroup>
{
#region IEqualityComparer implementation

View File

@@ -15,22 +15,14 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll.
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using KeePassLib;
namespace keepass2android
{
/// <summary>
/// EqualityComparer for PwUuid based on their value (instead of reference)
/// </summary>
public class PwUuidEqualityComparer: IEqualityComparer<PwUuid>
{
#region IEqualityComparer implementation

View File

@@ -1,5 +1,11 @@
namespace keepass2android
{
/// <summary>
/// Keys to identify user-displayable strings.
/// </summary>
/// Do not rename the keys here unless you rename the corresponding keys in the resource file of KP2A.
/// The keys are resolved by reflection to the static Resource class. This kind of duplication is necessary
/// in order to use the Resource mechanism of Android but still decouple the logic layer from the UI.
public enum UiStringKey
{
AskDeletePermanentlyGroup,

View File

@@ -139,7 +139,7 @@ namespace keepass2android
}
public PwGroup SearchForText(String str) {
PwGroup group = SearchHelper.searchForText(this, str);
PwGroup group = SearchHelper.SearchForText(this, str);
return group;
@@ -147,19 +147,19 @@ namespace keepass2android
public PwGroup Search(SearchParameters searchParams)
{
return SearchHelper.search(this, searchParams);
return SearchHelper.Search(this, searchParams);
}
public PwGroup SearchForExactUrl(String url) {
PwGroup group = SearchHelper.searchForExactUrl(this, url);
PwGroup group = SearchHelper.SearchForExactUrl(this, url);
return group;
}
public PwGroup SearchForHost(String url, bool allowSubdomains) {
PwGroup group = SearchHelper.searchForHost(this, url, allowSubdomains);
PwGroup group = SearchHelper.SearchForHost(this, url, allowSubdomains);
return group;

View File

@@ -110,12 +110,12 @@ namespace keepass2android
{
DeletePermanently = true;
ProgressTask pt = new ProgressTask(App, Ctx, this, UiStringKey.saving_database);
pt.run();
pt.Run();
},
(dlgSender, dlgEvt) => {
DeletePermanently = false;
ProgressTask pt = new ProgressTask(App, Ctx, this, UiStringKey.saving_database);
pt.run();
pt.Run();
},
(dlgSender, dlgEvt) => {},
Ctx);
@@ -125,7 +125,7 @@ namespace keepass2android
} else
{
ProgressTask pt = new ProgressTask(App, Ctx, this, UiStringKey.saving_database);
pt.run();
pt.Run();
}
}

View File

@@ -77,7 +77,7 @@ namespace keepass2android
private class AfterSave : OnFinish {
private readonly CompositeKey _backup;
private readonly DateTime _previousKeyChanged;
private PwDatabase _db;
private readonly PwDatabase _db;
public AfterSave(CompositeKey backup, DateTime previousKeyChanged, PwDatabase db, OnFinish finish): base(finish) {
_previousKeyChanged = previousKeyChanged;