Corrected some tests

Minor code refactor
Main page now correctly shows save page even when opening a DB from Explorer
This commit is contained in:
2018-09-12 12:58:32 +02:00
parent 38e2d1ac51
commit d341535d60
11 changed files with 50 additions and 56 deletions

View File

@@ -393,8 +393,8 @@
</Page>
</ItemGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Crypto, Version=1.8.2.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>..\packages\Portable.BouncyCastle.1.8.2\lib\netstandard1.0\BouncyCastle.Crypto.dll</HintPath>
<Reference Include="BouncyCastle.Crypto, Version=1.8.3.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>..\packages\Portable.BouncyCastle.1.8.3\lib\netstandard1.0\BouncyCastle.Crypto.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.HockeyApp.Core45, Version=4.1.6.1005, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@@ -421,24 +421,24 @@
<HintPath>..\packages\System.Collections.Immutable.1.5.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Composition.AttributedModel, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.AttributedModel.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll</HintPath>
<Reference Include="System.Composition.AttributedModel, Version=1.0.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.AttributedModel.1.2.0\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Composition.Convention, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.Convention.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll</HintPath>
<Reference Include="System.Composition.Convention, Version=1.0.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.Convention.1.2.0\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Composition.Hosting, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.Hosting.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll</HintPath>
<Reference Include="System.Composition.Hosting, Version=1.0.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.Hosting.1.2.0\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Composition.Runtime, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.Runtime.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll</HintPath>
<Reference Include="System.Composition.Runtime, Version=1.0.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.Runtime.1.2.0\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Composition.TypedParts, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.TypedParts.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll</HintPath>
<Reference Include="System.Composition.TypedParts, Version=1.0.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.TypedParts.1.2.0\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Drawing.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">

View File

@@ -62,7 +62,7 @@ namespace ModernKeePass.ViewModels
Destination = destinationFrame,
Parameter = databaseFile,
SymbolIcon = Symbol.Page2,
IsSelected = databaseFile != null
IsSelected = databaseFile != null && !database.IsOpen
},
new MainMenuItemVm
{

View File

@@ -12,16 +12,8 @@ namespace ModernKeePass.ViewModels
public string Name => DatabaseFile?.DisplayName;
public StorageFile DatabaseFile { get; private set; }
public OpenVm() : this(null) { }
public OpenVm(StorageFile file)
{
if (!IsFileSelected) return;
OpenFile(file);
}
public void OpenFile(StorageFile file)
internal void OpenFile(StorageFile file)
{
OpenFile(file, RecentService.Instance);
}

View File

@@ -10,16 +10,16 @@
<package id="Microsoft.Toolkit.Uwp.Notifications" version="2.0.0" targetFramework="win81" />
<package id="ModernKeePassLib" version="2.39.1" targetFramework="win81" />
<package id="NETStandard.Library" version="2.0.3" targetFramework="win81" />
<package id="Portable.BouncyCastle" version="1.8.2" targetFramework="win81" />
<package id="Portable.BouncyCastle" version="1.8.3" targetFramework="win81" />
<package id="Splat" version="3.0.0" targetFramework="win81" />
<package id="System.Collections" version="4.3.0" targetFramework="win81" />
<package id="System.Collections.Immutable" version="1.5.0" targetFramework="win81" />
<package id="System.Composition" version="1.0.31" targetFramework="win81" />
<package id="System.Composition.AttributedModel" version="1.0.31" targetFramework="win81" />
<package id="System.Composition.Convention" version="1.0.31" targetFramework="win81" />
<package id="System.Composition.Hosting" version="1.0.31" targetFramework="win81" />
<package id="System.Composition.Runtime" version="1.0.31" targetFramework="win81" />
<package id="System.Composition.TypedParts" version="1.0.31" targetFramework="win81" />
<package id="System.Composition" version="1.2.0" targetFramework="win81" />
<package id="System.Composition.AttributedModel" version="1.2.0" targetFramework="win81" />
<package id="System.Composition.Convention" version="1.2.0" targetFramework="win81" />
<package id="System.Composition.Hosting" version="1.2.0" targetFramework="win81" />
<package id="System.Composition.Runtime" version="1.2.0" targetFramework="win81" />
<package id="System.Composition.TypedParts" version="1.2.0" targetFramework="win81" />
<package id="System.Diagnostics.Contracts" version="4.3.0" targetFramework="win81" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="win81" />
<package id="System.Drawing.Primitives" version="4.3.0" targetFramework="win81" />

View File

@@ -3,21 +3,24 @@ using System.Collections.ObjectModel;
using System.Threading.Tasks;
using ModernKeePass.Interfaces;
using Windows.Storage;
using System.Collections.Generic;
namespace ModernKeePassApp.Test.Mock
{
class RecentServiceMock : IRecentService
{
private Dictionary<string, IStorageItem> _recentItems = new Dictionary<string, IStorageItem>();
public int EntryCount => 0;
public void Add(IStorageItem file, string metadata)
{
throw new NotImplementedException();
_recentItems.Add(metadata, file);
}
public void ClearAll()
{
throw new NotImplementedException();
_recentItems.Clear();
}
public ObservableCollection<IRecentItem> GetAllFiles(bool removeIfNonExistant = true)
@@ -27,7 +30,7 @@ namespace ModernKeePassApp.Test.Mock
public Task<IStorageItem> GetFileAsync(string token)
{
throw new NotImplementedException();
return Task.Run(() => _recentItems[token]);
}
}
}

View File

@@ -159,12 +159,12 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Crypto, Version=1.8.2.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>..\packages\Portable.BouncyCastle.1.8.2\lib\netstandard1.0\BouncyCastle.Crypto.dll</HintPath>
<Reference Include="BouncyCastle.Crypto, Version=1.8.3.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>..\packages\Portable.BouncyCastle.1.8.3\lib\netstandard1.0\BouncyCastle.Crypto.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ModernKeePassLib, Version=2.37.0.2000, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ModernKeePassLib.2.38.2\lib\netstandard1.2\ModernKeePassLib.dll</HintPath>
<Reference Include="ModernKeePassLib, Version=2.39.1.22027, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ModernKeePassLib.2.39.1\lib\netstandard1.2\ModernKeePassLib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Splat, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">

View File

@@ -63,9 +63,10 @@ namespace ModernKeePassApp.Test
{
var databaseFile = Package.Current.InstalledLocation.GetFileAsync(@"Data\TestDatabase.kdbx")
.GetAwaiter().GetResult();
var openVm = new OpenVm(databaseFile);
Assert.IsTrue(openVm.IsFileSelected);
Assert.AreEqual("MockDatabase", openVm.Name);
var openVm = new OpenVm();
Assert.IsFalse(openVm.IsFileSelected);
openVm.OpenFile(databaseFile, new RecentServiceMock());
Assert.AreEqual("TestDatabase.kdbx", openVm.Name);
}
/*[TestMethod]

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.NETCore.Platforms" version="2.1.0" targetFramework="win81" />
<package id="Microsoft.NETCore.Platforms" version="2.1.1" targetFramework="win81" />
<package id="Microsoft.NETCore.Portable.Compatibility" version="1.0.2" targetFramework="win81" />
<package id="ModernKeePassLib" version="2.38.2" targetFramework="win81" />
<package id="ModernKeePassLib" version="2.39.1" targetFramework="win81" />
<package id="NETStandard.Library" version="2.0.3" targetFramework="win81" />
<package id="Portable.BouncyCastle" version="1.8.2" targetFramework="win81" />
<package id="Portable.BouncyCastle" version="1.8.3" targetFramework="win81" />
<package id="Splat" version="3.0.0" targetFramework="win81" />
<package id="System.Diagnostics.Contracts" version="4.3.0" targetFramework="win81" />
<package id="System.Drawing.Primitives" version="4.3.0" targetFramework="win81" />

View File

@@ -23,7 +23,7 @@ namespace ModernKeePassLib.Test.Keys
"\t\t<Data>";
private const string ExpectedFileEnd = "\t</Key>\r\n" +
"</KeyFile>\r\n";
"</KeyFile>";
[TestMethod]
public void TestConstruct()
@@ -70,7 +70,7 @@ namespace ModernKeePassLib.Test.Keys
{
var fileContents = FileIO.ReadTextAsync(file).GetAwaiter().GetResult();
Assert.AreEqual(fileContents.Length, 187);
Assert.AreEqual(185, fileContents.Length);
Assert.IsTrue(fileContents.StartsWith(ExpectedFileStart));
Assert.IsTrue(fileContents.EndsWith(ExpectedFileEnd));
}

View File

@@ -148,8 +148,12 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Crypto, Version=1.8.2.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>..\packages\Portable.BouncyCastle.1.8.2\lib\netstandard1.0\BouncyCastle.Crypto.dll</HintPath>
<Reference Include="BouncyCastle.Crypto, Version=1.8.3.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>..\packages\Portable.BouncyCastle.1.8.3\lib\netstandard1.0\BouncyCastle.Crypto.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ModernKeePassLib, Version=2.39.1.22027, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ModernKeePassLib.2.39.1\lib\netstandard1.2\ModernKeePassLib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Splat, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
@@ -183,12 +187,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ModernKeePassLib\ModernKeePass.Lib.csproj">
<Project>{2e710089-9559-4967-846c-e763dd1f3acb}</Project>
<Name>ModernKeePass.Lib</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.NETCore.Platforms" version="2.1.0" targetFramework="win81" />
<package id="Microsoft.NETCore.Platforms" version="2.1.1" targetFramework="win81" />
<package id="Microsoft.NETCore.Portable.Compatibility" version="1.0.2" targetFramework="win81" />
<package id="ModernKeePassLib" version="2.38.2" targetFramework="win81" />
<package id="ModernKeePassLib" version="2.39.1" targetFramework="win81" />
<package id="NETStandard.Library" version="2.0.3" targetFramework="win81" />
<package id="Portable.BouncyCastle" version="1.8.2" targetFramework="win81" />
<package id="Portable.BouncyCastle" version="1.8.3" targetFramework="win81" />
<package id="Splat" version="3.0.0" targetFramework="win81" />
<package id="System.Collections" version="4.3.0" targetFramework="win81" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="win81" />