mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Added some tests
Removed false first group, replaced it a button in the header Code refactor
This commit is contained in:
@@ -434,10 +434,8 @@
|
|||||||
<Content Include="Assets\Wide310x150Logo.scale-140.png" />
|
<Content Include="Assets\Wide310x150Logo.scale-140.png" />
|
||||||
<Content Include="Assets\Wide310x150Logo.scale-180.png" />
|
<Content Include="Assets\Wide310x150Logo.scale-180.png" />
|
||||||
<Content Include="Assets\Wide310x150Logo.scale-80.png" />
|
<Content Include="Assets\Wide310x150Logo.scale-80.png" />
|
||||||
<Content Include="Data\WindowsStoreProxy.xml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0' ">
|
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0' ">
|
||||||
<VisualStudioVersion>12.0</VisualStudioVersion>
|
<VisualStudioVersion>12.0</VisualStudioVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Windows.ApplicationModel;
|
|
||||||
using Windows.ApplicationModel.Store;
|
using Windows.ApplicationModel.Store;
|
||||||
using ModernKeePass.Interfaces;
|
using ModernKeePass.Interfaces;
|
||||||
|
|
||||||
@@ -27,34 +26,13 @@ namespace ModernKeePass.Services
|
|||||||
|
|
||||||
public LicenseService()
|
public LicenseService()
|
||||||
{
|
{
|
||||||
// Initialize the license info for use in the app that is uploaded to the Store.
|
|
||||||
// Uncomment the following line in the release version of your app.
|
|
||||||
//_licenseInformation = CurrentApp.LicenseInformation;
|
|
||||||
|
|
||||||
// Initialize the license info for testing.
|
|
||||||
// Comment the following line in the release version of your app.
|
|
||||||
//_licenseInformation = CurrentAppSimulator.LicenseInformation;
|
|
||||||
#if DEBUG
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var proxyFile = Package.Current.InstalledLocation.GetFileAsync("data\\WindowsStoreProxy.xml").GetAwaiter().GetResult();
|
|
||||||
CurrentAppSimulator.ReloadSimulatorAsync(proxyFile).GetAwaiter().GetResult();
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
var listing = CurrentAppSimulator.LoadListingInformationAsync().GetAwaiter().GetResult();
|
|
||||||
#else
|
|
||||||
var listing = CurrentApp.LoadListingInformationAsync().GetAwaiter().GetResult();
|
var listing = CurrentApp.LoadListingInformationAsync().GetAwaiter().GetResult();
|
||||||
#endif
|
|
||||||
Products = listing.ProductListings;
|
Products = listing.ProductListings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> Purchase(string addOn)
|
public async Task<int> Purchase(string addOn)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
|
||||||
var purchaseResults = await CurrentAppSimulator.RequestProductPurchaseAsync(addOn);
|
|
||||||
#else
|
|
||||||
var purchaseResults = await CurrentApp.RequestProductPurchaseAsync(addOn);
|
var purchaseResults = await CurrentApp.RequestProductPurchaseAsync(addOn);
|
||||||
#endif
|
|
||||||
switch (purchaseResults.Status)
|
switch (purchaseResults.Status)
|
||||||
{
|
{
|
||||||
case ProductPurchaseStatus.Succeeded:
|
case ProductPurchaseStatus.Succeeded:
|
||||||
@@ -79,11 +57,7 @@ namespace ModernKeePass.Services
|
|||||||
|
|
||||||
private async Task<PurchaseResult> ReportFulfillmentAsync(Guid transactionId, string productName)
|
private async Task<PurchaseResult> ReportFulfillmentAsync(Guid transactionId, string productName)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
|
||||||
var result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync(productName, transactionId);
|
|
||||||
#else
|
|
||||||
var result = await CurrentApp.ReportConsumableFulfillmentAsync(productName, transactionId);
|
var result = await CurrentApp.ReportConsumableFulfillmentAsync(productName, transactionId);
|
||||||
#endif
|
|
||||||
return (PurchaseResult) result;
|
return (PurchaseResult) result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -175,7 +175,7 @@
|
|||||||
<value>Donate</value>
|
<value>Donate</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="DonateDesc.Text" xml:space="preserve">
|
<data name="DonateDesc.Text" xml:space="preserve">
|
||||||
<value>Like this app? Why not make a small donation to support my work and help this app stay ad-free :) ?</value>
|
<value>Like this app? Why not make a small donation to support my work and help me keep it ad-free :) ?</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="EntryExpirationDate.Content" xml:space="preserve">
|
<data name="EntryExpirationDate.Content" xml:space="preserve">
|
||||||
<value>Expiration date</value>
|
<value>Expiration date</value>
|
||||||
|
@@ -61,7 +61,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_pwGroup == null) return Symbol.Add;
|
//if (_pwGroup == null) return Symbol.Add;
|
||||||
var result = PwIconToSegoeMapping.GetSymbolFromIcon(_pwGroup.IconId);
|
var result = PwIconToSegoeMapping.GetSymbolFromIcon(_pwGroup.IconId);
|
||||||
return result == Symbol.More ? Symbol.Folder : result;
|
return result == Symbol.More ? Symbol.Folder : result;
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,6 @@ namespace ModernKeePass.ViewModels
|
|||||||
Entries = new ObservableCollection<EntryVm>(pwGroup.Entries.Select(e => new EntryVm(e, this)));
|
Entries = new ObservableCollection<EntryVm>(pwGroup.Entries.Select(e => new EntryVm(e, this)));
|
||||||
Entries.CollectionChanged += Entries_CollectionChanged;
|
Entries.CollectionChanged += Entries_CollectionChanged;
|
||||||
Groups = new ObservableCollection<GroupVm>(pwGroup.Groups.Select(g => new GroupVm(g, this, recycleBinId)));
|
Groups = new ObservableCollection<GroupVm>(pwGroup.Groups.Select(g => new GroupVm(g, this, recycleBinId)));
|
||||||
Groups.Insert(0, new GroupVm());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Entries_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
private void Entries_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||||
|
@@ -94,6 +94,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
_database = database;
|
_database = database;
|
||||||
Groups = _database?.RootGroup.Groups;
|
Groups = _database?.RootGroup.Groups;
|
||||||
|
Groups?.Insert(0, new GroupVm());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -126,7 +126,7 @@
|
|||||||
RequestedTheme="Dark"
|
RequestedTheme="Dark"
|
||||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||||
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}">
|
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}">
|
||||||
<ListView.Resources>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate x:Name="GroupOtherItem">
|
<DataTemplate x:Name="GroupOtherItem">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<SymbolIcon Symbol="{Binding IconSymbol}" Margin="8,0,0,0">
|
<SymbolIcon Symbol="{Binding IconSymbol}" Margin="8,0,0,0">
|
||||||
@@ -137,17 +137,7 @@
|
|||||||
<TextBlock Text="{Binding Name}" x:Name="GroupTextBlock" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="30,0,20,0" FontStyle="{Binding IsSelected, Converter={StaticResource BooleanToFontStyleConverter}}" />
|
<TextBlock Text="{Binding Name}" x:Name="GroupTextBlock" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="30,0,20,0" FontStyle="{Binding IsSelected, Converter={StaticResource BooleanToFontStyleConverter}}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<DataTemplate x:Name="GroupFirstItem">
|
</ListView.ItemTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<SymbolIcon Symbol="{Binding IconSymbol}" Margin="8,0,0,0">
|
|
||||||
<ToolTipService.ToolTip>
|
|
||||||
<ToolTip x:Uid="GroupNewItemTooltip" />
|
|
||||||
</ToolTipService.ToolTip>
|
|
||||||
</SymbolIcon>
|
|
||||||
<TextBlock x:Name="GroupTextBlock" x:Uid="GroupNewItemTextBox" FontWeight="SemiBold" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="30,0,20,0" />
|
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
|
||||||
</ListView.Resources>
|
|
||||||
<ListView.ItemsSource>
|
<ListView.ItemsSource>
|
||||||
<Binding Source="{StaticResource GroupsViewSource}"/>
|
<Binding Source="{StaticResource GroupsViewSource}"/>
|
||||||
</ListView.ItemsSource>
|
</ListView.ItemsSource>
|
||||||
@@ -161,6 +151,7 @@
|
|||||||
</ListView.ItemContainerStyle>
|
</ListView.ItemContainerStyle>
|
||||||
<ListView.HeaderTemplate>
|
<ListView.HeaderTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
<ToggleButton Style="{StaticResource HamburgerToggleButton}">
|
<ToggleButton Style="{StaticResource HamburgerToggleButton}">
|
||||||
<interactivity:Interaction.Behaviors>
|
<interactivity:Interaction.Behaviors>
|
||||||
<core:EventTriggerBehavior EventName="Checked">
|
<core:EventTriggerBehavior EventName="Checked">
|
||||||
@@ -171,13 +162,20 @@
|
|||||||
</core:EventTriggerBehavior>
|
</core:EventTriggerBehavior>
|
||||||
</interactivity:Interaction.Behaviors>
|
</interactivity:Interaction.Behaviors>
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
|
<Button Padding="0" Height="50" Margin="0" Style="{StaticResource NoBorderButtonStyle}" Background="Transparent" Foreground="White" BorderThickness="0" Click="CreateGroup_ButtonClick">
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="13,0,5,0">
|
||||||
|
<SymbolIcon Symbol="Add">
|
||||||
|
<ToolTipService.ToolTip>
|
||||||
|
<ToolTip x:Uid="GroupNewItemTooltip" />
|
||||||
|
</ToolTipService.ToolTip>
|
||||||
|
</SymbolIcon>
|
||||||
|
<TextBlock x:Uid="GroupNewItemTextBox" FontWeight="SemiBold" TextWrapping="NoWrap" FontSize="16" VerticalAlignment="Center" Margin="30,0,20,0" />
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
<Border BorderBrush="White" BorderThickness="0,0,0,1" />
|
||||||
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListView.HeaderTemplate>
|
</ListView.HeaderTemplate>
|
||||||
<ListView.ItemTemplateSelector>
|
|
||||||
<templateSelectors:FirstItemDataTemplateSelector
|
|
||||||
FirstItem="{StaticResource GroupFirstItem}"
|
|
||||||
OtherItem="{StaticResource GroupOtherItem}" />
|
|
||||||
</ListView.ItemTemplateSelector>
|
|
||||||
</ListView>
|
</ListView>
|
||||||
<TextBlock Grid.Column="1" x:Uid="ReorderEntriesLabel" Margin="20,20,0,0" Visibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource BodyTextBlockStyle}" />
|
<TextBlock Grid.Column="1" x:Uid="ReorderEntriesLabel" Margin="20,20,0,0" Visibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource BodyTextBlockStyle}" />
|
||||||
<HyperlinkButton Grid.Column="1" VerticalAlignment="Top" Margin="40,10,0,0" Click="CreateEntry_ButtonClick" Visibility="{Binding IsSelected, Converter={StaticResource InverseBooleanToVisibilityConverter}}" HorizontalAlignment="Right">
|
<HyperlinkButton Grid.Column="1" VerticalAlignment="Top" Margin="40,10,0,0" Click="CreateEntry_ButtonClick" Visibility="{Binding IsSelected, Converter={StaticResource InverseBooleanToVisibilityConverter}}" HorizontalAlignment="Right">
|
||||||
@@ -370,13 +368,18 @@
|
|||||||
<SymbolIcon Symbol="Find" />
|
<SymbolIcon Symbol="Find" />
|
||||||
<Button.Flyout>
|
<Button.Flyout>
|
||||||
<Flyout>
|
<Flyout>
|
||||||
|
<Flyout.FlyoutPresenterStyle>
|
||||||
|
<Style TargetType="FlyoutPresenter">
|
||||||
|
<Setter Property="Padding" Value="0" />
|
||||||
|
</Style>
|
||||||
|
</Flyout.FlyoutPresenterStyle>
|
||||||
<!--<controls:TextBoxWithButton x:Uid="GroupFilter" ButtonSymbol="" Text="{Binding Filter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="18" VerticalContentAlignment="Center" Width="400" Style="{StaticResource TextBoxWithButtonStyle}" IsButtonEnabled="False" />-->
|
<!--<controls:TextBoxWithButton x:Uid="GroupFilter" ButtonSymbol="" Text="{Binding Filter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="18" VerticalContentAlignment="Center" Width="400" Style="{StaticResource TextBoxWithButtonStyle}" IsButtonEnabled="False" />-->
|
||||||
<SearchBox x:Uid="GroupSearch" Width="350" Background="{ThemeResource TextBoxDisabledBackgroundThemeBrush}" BorderThickness="0" FontSize="18" SuggestionsRequested="SearchBox_OnSuggestionsRequested" SearchHistoryEnabled="False" ResultSuggestionChosen="SearchBox_OnResultSuggestionChosen" VerticalContentAlignment="Center" />
|
<SearchBox x:Uid="GroupSearch" Width="350" Padding="12" Background="{ThemeResource TextBoxDisabledBackgroundThemeBrush}" BorderThickness="0" FontSize="18" SuggestionsRequested="SearchBox_OnSuggestionsRequested" SearchHistoryEnabled="False" ResultSuggestionChosen="SearchBox_OnResultSuggestionChosen" />
|
||||||
</Flyout>
|
</Flyout>
|
||||||
</Button.Flyout>
|
</Button.Flyout>
|
||||||
</Button>
|
</Button>
|
||||||
<!--<controls:TextBoxWithButton Grid.Column="2" x:Name="FilterBox" x:Uid="GroupFilter" ButtonSymbol="" Text="{Binding Filter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="18" VerticalContentAlignment="Center" Width="400" Style="{StaticResource TextBoxWithButtonStyle}" IsButtonEnabled="False" />-->
|
<!--<controls:TextBoxWithButton Grid.Column="2" x:Name="FilterBox" x:Uid="GroupFilter" ButtonSymbol="" Text="{Binding Filter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="18" VerticalContentAlignment="Center" Width="400" Style="{StaticResource TextBoxWithButtonStyle}" IsButtonEnabled="False" />-->
|
||||||
<SearchBox Grid.Column="2" x:Uid="GroupSearch" x:Name="SearchBox" Width="350" Background="{ThemeResource TextBoxDisabledBackgroundThemeBrush}" BorderThickness="0" FontSize="18" SuggestionsRequested="SearchBox_OnSuggestionsRequested" SearchHistoryEnabled="False" ResultSuggestionChosen="SearchBox_OnResultSuggestionChosen" VerticalContentAlignment="Center" />
|
<SearchBox Grid.Column="2" x:Uid="GroupSearch" x:Name="SearchBox" Padding="12" Width="350" Background="{ThemeResource TextBoxDisabledBackgroundThemeBrush}" BorderThickness="0" FontSize="18" SuggestionsRequested="SearchBox_OnSuggestionsRequested" SearchHistoryEnabled="False" ResultSuggestionChosen="SearchBox_OnResultSuggestionChosen" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<VisualStateManager.VisualStateGroups>
|
<VisualStateManager.VisualStateGroups>
|
||||||
<VisualStateGroup x:Name="DragDropGroup">
|
<VisualStateGroup x:Name="DragDropGroup">
|
||||||
|
@@ -84,9 +84,6 @@ namespace ModernKeePass.Views
|
|||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
return;
|
return;
|
||||||
case 0:
|
|
||||||
group = Model.AddNewGroup();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
group = LeftListView.SelectedItem as GroupVm;
|
group = LeftListView.SelectedItem as GroupVm;
|
||||||
break;
|
break;
|
||||||
@@ -145,6 +142,10 @@ namespace ModernKeePass.Views
|
|||||||
{
|
{
|
||||||
Frame.Navigate(typeof(EntryDetailPage), Model.AddNewEntry());
|
Frame.Navigate(typeof(EntryDetailPage), Model.AddNewEntry());
|
||||||
}
|
}
|
||||||
|
private void CreateGroup_ButtonClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Frame.Navigate(typeof(GroupDetailPage), Model.AddNewGroup());
|
||||||
|
}
|
||||||
|
|
||||||
private void GridView_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
|
private void GridView_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
|
||||||
{
|
{
|
||||||
|
@@ -28,7 +28,7 @@ namespace ModernKeePassApp.Test
|
|||||||
public void TestOpen()
|
public void TestOpen()
|
||||||
{
|
{
|
||||||
Assert.AreEqual((int)DatabaseService.DatabaseStatus.Closed, _database.Status);
|
Assert.AreEqual((int)DatabaseService.DatabaseStatus.Closed, _database.Status);
|
||||||
_database.DatabaseFile = Package.Current.InstalledLocation.GetFileAsync(@"Databases\TestDatabase.kdbx").GetAwaiter().GetResult();
|
_database.DatabaseFile = Package.Current.InstalledLocation.GetFileAsync(@"Data\TestDatabase.kdbx").GetAwaiter().GetResult();
|
||||||
Assert.AreEqual((int)DatabaseService.DatabaseStatus.Opening, _database.Status);
|
Assert.AreEqual((int)DatabaseService.DatabaseStatus.Opening, _database.Status);
|
||||||
OpenOrCreateDatabase(false);
|
OpenOrCreateDatabase(false);
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ namespace ModernKeePassApp.Test.Mock
|
|||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
// Do Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save(StorageFile file)
|
public void Save(StorageFile file)
|
||||||
|
31
ModernKeePassApp.Test/Mock/LicenseServiceMock.cs
Normal file
31
ModernKeePassApp.Test/Mock/LicenseServiceMock.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Windows.ApplicationModel;
|
||||||
|
using Windows.ApplicationModel.Store;
|
||||||
|
using ModernKeePass.Interfaces;
|
||||||
|
|
||||||
|
namespace ModernKeePassApp.Test.Mock
|
||||||
|
{
|
||||||
|
public class LicenseServiceMock: ILicenseService
|
||||||
|
{
|
||||||
|
public IReadOnlyDictionary<string, ProductListing> Products { get; }
|
||||||
|
|
||||||
|
public LicenseServiceMock()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var proxyFile = Package.Current.InstalledLocation.GetFileAsync("data\\WindowsStoreProxy.xml").GetAwaiter().GetResult();
|
||||||
|
CurrentAppSimulator.ReloadSimulatorAsync(proxyFile).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
var listing = CurrentAppSimulator.LoadListingInformationAsync().GetAwaiter().GetResult();
|
||||||
|
Products = listing.ProductListings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<int> Purchase(string addOn)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -121,6 +121,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="DatabaseTests.cs" />
|
<Compile Include="DatabaseTests.cs" />
|
||||||
<Compile Include="Mock\DatabaseServiceMock.cs" />
|
<Compile Include="Mock\DatabaseServiceMock.cs" />
|
||||||
|
<Compile Include="Mock\LicenseServiceMock.cs" />
|
||||||
<Compile Include="Mock\RecentServiceMock.cs" />
|
<Compile Include="Mock\RecentServiceMock.cs" />
|
||||||
<Compile Include="Mock\ResourceServiceMock.cs" />
|
<Compile Include="Mock\ResourceServiceMock.cs" />
|
||||||
<Compile Include="Mock\SettingsServiceMock.cs" />
|
<Compile Include="Mock\SettingsServiceMock.cs" />
|
||||||
@@ -131,11 +132,14 @@
|
|||||||
<AppxManifest Include="Package.appxmanifest">
|
<AppxManifest Include="Package.appxmanifest">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</AppxManifest>
|
</AppxManifest>
|
||||||
<Content Include="Databases\TestDatabase.kdbx" />
|
<Content Include="Data\TestDatabase.kdbx" />
|
||||||
<None Include="ModernKeePassApp.Test_TemporaryKey.pfx" />
|
<None Include="ModernKeePassApp.Test_TemporaryKey.pfx" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="Data\WindowsStoreProxy.xml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Content>
|
||||||
<Content Include="Images\UnitTestLogo.scale-100.png">
|
<Content Include="Images\UnitTestLogo.scale-100.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
@@ -6,6 +6,7 @@ using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
|||||||
using ModernKeePass.ViewModels;
|
using ModernKeePass.ViewModels;
|
||||||
using ModernKeePass.Views;
|
using ModernKeePass.Views;
|
||||||
using ModernKeePassApp.Test.Mock;
|
using ModernKeePassApp.Test.Mock;
|
||||||
|
using ModernKeePassLib;
|
||||||
|
|
||||||
namespace ModernKeePassApp.Test
|
namespace ModernKeePassApp.Test
|
||||||
{
|
{
|
||||||
@@ -56,13 +57,20 @@ namespace ModernKeePassApp.Test
|
|||||||
Assert.AreEqual(15.0, compositeKeyVm.PasswordComplexityIndicator);
|
Assert.AreEqual(15.0, compositeKeyVm.PasswordComplexityIndicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestDonateVm()
|
||||||
|
{
|
||||||
|
var donateVm = new DonateVm(new LicenseServiceMock());
|
||||||
|
Assert.AreEqual(4, donateVm.Donations.Count);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestOpenVm()
|
public void TestOpenVm()
|
||||||
{
|
{
|
||||||
var database = new DatabaseServiceMock
|
var database = new DatabaseServiceMock
|
||||||
{
|
{
|
||||||
Status = 1,
|
Status = 1,
|
||||||
DatabaseFile = Package.Current.InstalledLocation.GetFileAsync(@"Databases\TestDatabase.kdbx")
|
DatabaseFile = Package.Current.InstalledLocation.GetFileAsync(@"Data\TestDatabase.kdbx")
|
||||||
.GetAwaiter().GetResult()
|
.GetAwaiter().GetResult()
|
||||||
};
|
};
|
||||||
var openVm = new OpenVm(database);
|
var openVm = new OpenVm(database);
|
||||||
@@ -79,7 +87,7 @@ namespace ModernKeePassApp.Test
|
|||||||
public void TestRecentVm()
|
public void TestRecentVm()
|
||||||
{
|
{
|
||||||
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
||||||
mru.Add(Package.Current.InstalledLocation.GetFileAsync(@"Databases\TestDatabase.kdbx")
|
mru.Add(Package.Current.InstalledLocation.GetFileAsync(@"Data\TestDatabase.kdbx")
|
||||||
.GetAwaiter().GetResult(), "MockDatabase");
|
.GetAwaiter().GetResult(), "MockDatabase");
|
||||||
var recentVm = new RecentVm();
|
var recentVm = new RecentVm();
|
||||||
Assert.IsTrue(recentVm.RecentItems.Count == 1);
|
Assert.IsTrue(recentVm.RecentItems.Count == 1);
|
||||||
@@ -88,10 +96,19 @@ namespace ModernKeePassApp.Test
|
|||||||
mru.Clear();
|
mru.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*[TestMethod]
|
[TestMethod]
|
||||||
public void TestSaveVm()
|
public void TestSaveVm()
|
||||||
{
|
{
|
||||||
}*/
|
var database = new DatabaseServiceMock
|
||||||
|
{
|
||||||
|
Status = 2
|
||||||
|
};
|
||||||
|
var saveVm = new SaveVm(database);
|
||||||
|
saveVm.Save(false);
|
||||||
|
Assert.AreEqual(2, database.Status);
|
||||||
|
saveVm.Save();
|
||||||
|
Assert.AreEqual(0, database.Status);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestSettingsVm()
|
public void TestSettingsVm()
|
||||||
@@ -105,5 +122,33 @@ namespace ModernKeePassApp.Test
|
|||||||
var selectedItem = (ListMenuItemVm) settingsVm.SelectedItem;
|
var selectedItem = (ListMenuItemVm) settingsVm.SelectedItem;
|
||||||
Assert.AreEqual(typeof(SettingsNewDatabasePage), selectedItem.PageType);
|
Assert.AreEqual(typeof(SettingsNewDatabasePage), selectedItem.PageType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestEntryVm()
|
||||||
|
{
|
||||||
|
var database = new DatabaseServiceMock
|
||||||
|
{
|
||||||
|
Status = 2
|
||||||
|
};
|
||||||
|
var entryVm = new EntryVm(new PwEntry(true, true), new GroupVm(), database)
|
||||||
|
{
|
||||||
|
Name = "Test",
|
||||||
|
UserName = "login",
|
||||||
|
Password = "password"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestGroupVm()
|
||||||
|
{
|
||||||
|
var database = new DatabaseServiceMock
|
||||||
|
{
|
||||||
|
Status = 2
|
||||||
|
};
|
||||||
|
var entryVm = new GroupVm(new PwGroup(true, true), new GroupVm(), database)
|
||||||
|
{
|
||||||
|
Name = "Test"
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user