Projektdateien hinzufügen.

This commit is contained in:
Kevin Krüger
2023-07-24 12:00:34 +02:00
parent 656751e10b
commit 0d00a90942
210 changed files with 45049 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
namespace VideoBrowser.Test.Common
{
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VideoBrowser.Common;
/// <summary>
/// Defines the <see cref="ByteFormatProviderTest" />
/// </summary>
[TestClass]
public class ByteFormatProviderTest
{
#region Methods
/// <summary>
/// The FileSizeFormatProvider_With_String
/// </summary>
[TestMethod]
public void ByteSizeFormatProvider_With_String()
{
var provider = new ByteFormatProvider();
var size = 1000000.0;
var formatedSize = string.Format(new ByteFormatProvider(), "{0:fs}", size);
formatedSize.Should().Be("976.56 KB");
var speed = 1000000000.0;
var formatedSpeed = string.Format(new ByteFormatProvider(), "{0:s}", speed);
formatedSpeed.Should().Be("953.67 MB/s");
}
#endregion Methods
}
}

View File

@@ -0,0 +1,31 @@
namespace VideoBrowser.Test.Common
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
/// <summary>
/// Defines the <see cref="ManualTestAttribute" />.
/// </summary>
public class ManualTestAttribute : TestCategoryBaseAttribute
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="ManualTestAttribute"/> class.
/// </summary>
public ManualTestAttribute()
{
}
#endregion Constructors
#region Properties
/// <summary>
/// Gets the TestCategories.
/// </summary>
public override IList<string> TestCategories => new List<string> { "ManualTest" };
#endregion Properties
}
}

View File

@@ -0,0 +1,28 @@
namespace VideoBrowser.Test.Common
{
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VideoBrowser.Common;
/// <summary>
/// Defines the <see cref="PercentageTest" />
/// </summary>
[TestClass]
public class PercentageTest
{
#region Methods
/// <summary>
/// The PercentageTest_Constructor
/// </summary>
[TestMethod]
public void PercentageTest_Constructor()
{
var percentage = new Percentage(50);
percentage.Normalized.Should().Be(0.5);
percentage.ToString().Should().Be("50%");
}
#endregion Methods
}
}

View File

@@ -0,0 +1,42 @@
namespace VideoBrowser.Test.Extensions
{
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VideoBrowser.Extensions;
/// <summary>
/// Defines the <see cref="StringExtensionTest" />
/// </summary>
[TestClass]
public class StringExtensionTest
{
#region Methods
/// <summary>
/// The ToFormatedByte
/// </summary>
[TestMethod]
public void ToFormatedByte()
{
var formatedByte = StringExtension.ToFormatedByte(10000);
formatedByte.Should().Be("9.77 KB");
formatedByte = StringExtension.ToFormatedByte(20000000);
formatedByte.Should().Be("19.07 MB");
formatedByte = StringExtension.ToFormatedByte(2000000000);
formatedByte.Should().Be("1.86 GB");
}
[TestMethod]
public void ToFormatedSpeed()
{
var formatedSpeed = StringExtension.ToFormatedSpeed(10000);
formatedSpeed.Should().Be("9.77 KB/s");
formatedSpeed = StringExtension.ToFormatedSpeed(20000000);
formatedSpeed.Should().Be("19.07 MB/s");
formatedSpeed = StringExtension.ToFormatedSpeed(2000000000);
formatedSpeed.Should().Be("1.86 GB/s");
}
#endregion Methods
}
}

View File

@@ -0,0 +1,52 @@
namespace VideoBrowser.Test.Models
{
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.ObjectModel;
using VideoBrowser.Models;
using VideoBrowser.Test.TestHelpers;
/// <summary>
/// Defines the <see cref="OperationModelTest" />.
/// </summary>
[TestClass]
public class OperationModelTest
{
#region Methods
/// <summary>
/// The Test.
/// </summary>
[TestMethod]
public void ContainsTest()
{
var operation1 = new DummyOperation
{
Output = "NewVideo1.mp4"
};
var operation2 = new DummyOperation
{
Output = "NewVideo2.mp4"
};
var operation3 = new DummyOperation
{
Output = "NewVideo1.mp4"
};
var model1 = new OperationModel(operation1);
var model2 = new OperationModel(operation2);
var model3 = new OperationModel(operation3);
var models = new ObservableCollection<OperationModel>
{
model1,
model2
};
models.Contains(model1).Should().BeTrue();
models.Contains(model2).Should().BeTrue();
models.Contains(model3).Should().BeTrue();
}
#endregion Methods
}
}

View File

@@ -0,0 +1,17 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("VideoBrowser.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VideoBrowser.Test")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("ceb9d499-9f24-42c0-b6ad-165d2abf9b7b")]
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.7.0")]
[assembly: AssemblyFileVersion("0.1.7.0")]

View File

@@ -0,0 +1,39 @@
namespace VideoBrowser.Test.TestHelpers
{
using System.ComponentModel;
using VideoBrowser.Core;
/// <summary>
/// Defines the <see cref="DummyOperation" />.
/// </summary>
public class DummyOperation : Operation
{
#region Methods
/// <summary>
/// The WorkerCompleted.
/// </summary>
/// <param name="e">The e<see cref="RunWorkerCompletedEventArgs"/>.</param>
protected override void WorkerCompleted(RunWorkerCompletedEventArgs e)
{
}
/// <summary>
/// The WorkerDoWork.
/// </summary>
/// <param name="e">The e<see cref="DoWorkEventArgs"/>.</param>
protected override void WorkerDoWork(DoWorkEventArgs e)
{
}
/// <summary>
/// The WorkerProgressChanged.
/// </summary>
/// <param name="e">The e<see cref="ProgressChangedEventArgs"/>.</param>
protected override void WorkerProgressChanged(ProgressChangedEventArgs e)
{
}
#endregion Methods
}
}

View File

@@ -0,0 +1,47 @@
namespace VideoBrowser.Test.TestHelpers
{
using System;
/// <summary>
/// Defines the <see cref="TestHelper" />.
/// </summary>
internal static class TestHelper
{
#region Properties
/// <summary>
/// Gets the Random.
/// </summary>
private static Random Random { get; } = new Random();
#endregion Properties
#region Methods
/// <summary>
/// The GetRandomInt.
/// </summary>
/// <param name="start">The start<see cref="int"/>.</param>
/// <param name="end">The end<see cref="int"/>.</param>
/// <returns>The <see cref="long"/>.</returns>
internal static int GetRandomInt(int start, int end)
{
var random = start + Random.NextDouble() * (end - start);
return (int)random;
}
/// <summary>
/// The GetRandomLong.
/// </summary>
/// <param name="start">The start<see cref="long"/>.</param>
/// <param name="end">The end<see cref="long"/>.</param>
/// <returns>The <see cref="long"/>.</returns>
internal static long GetRandomLong(long start, long end)
{
var random = start + Random.NextDouble() * (end - start);
return (long)random;
}
#endregion Methods
}
}

View File

@@ -0,0 +1,24 @@
namespace VideoBrowser.Test.TestHelpers
{
using System.Windows;
/// <summary>
/// Defines the <see cref="WindowFactory" />.
/// </summary>
internal static class WindowFactory
{
#region Methods
/// <summary>
/// The CreateAndShow.
/// </summary>
/// <param name="view">The view<see cref="FrameworkElement"/>.</param>
internal static void CreateAndShow(FrameworkElement view)
{
var window = new Window { Content = view, MinWidth = 600, MinHeight = 400, SizeToContent = SizeToContent.WidthAndHeight };
window.ShowDialog();
}
#endregion Methods
}
}

View File

@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CEB9D499-9F24-42C0-B6AD-165D2ABF9B7B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>VideoBrowser.Test</RootNamespace>
<AssemblyName>VideoBrowser.Test</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentAssertions">
<HintPath>..\..\..\bin\FluentAssertions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Common\ByteFormatProviderTest.cs" />
<Compile Include="Common\ManualTestAttribute.cs" />
<Compile Include="Common\PercentageTest.cs" />
<Compile Include="Models\OperationModelTest.cs" />
<Compile Include="TestHelpers\DummyOperation.cs" />
<Compile Include="TestHelpers\TestHelper.cs" />
<Compile Include="TestHelpers\WindowFactory.cs" />
<Compile Include="Extensions\StringExtensionTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Views\UrlEditorViewTest.cs" />
<Compile Include="Views\SettingsViewTest.cs" />
<Compile Include="Views\AboutViewTest.cs" />
<Compile Include="Views\DownloadQueueViewTest.cs" />
</ItemGroup>
<ItemGroup>
<None Include="key.snk" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VideoBrowser\VideoBrowser.csproj">
<Project>{2d8225bc-f5b6-4f29-a9e3-f4694d260597}</Project>
<Name>VideoBrowser</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter">
<Version>2.2.7</Version>
</PackageReference>
<PackageReference Include="MSTest.TestFramework">
<Version>2.2.7</Version> </PackageReference>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,30 @@
namespace VideoBrowser.Test.Views
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VideoBrowser.Test.Common;
using VideoBrowser.Test.TestHelpers;
using VideoBrowser.ViewModels;
using VideoBrowser.Views;
/// <summary>
/// Defines the <see cref="AboutViewTest" />.
/// </summary>
[TestClass]
public class AboutViewTest
{
#region Methods
/// <summary>
/// The Show_AboutView.
/// </summary>
[TestMethod, ManualTest]
public void Show_AboutView()
{
var viewModel = new AboutViewModel();
var view = new AboutView { DataContext = viewModel };
WindowFactory.CreateAndShow(view);
}
#endregion Methods
}
}

View File

@@ -0,0 +1,69 @@
namespace VideoBrowser.Test.Views
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.ObjectModel;
using System.Windows.Input;
using VideoBrowser.Controls.CefSharpBrowser;
using VideoBrowser.Controls.CefSharpBrowser.Models;
using VideoBrowser.Core;
using VideoBrowser.Models;
using VideoBrowser.Test.Common;
using VideoBrowser.Test.TestHelpers;
using VideoBrowser.ViewModels;
using VideoBrowser.Views;
/// <summary>
/// Defines the <see cref="DownloadQueueViewTest" />.
/// </summary>
[TestClass]
public class DownloadQueueViewTest
{
#region Methods
/// <summary>
/// The Show_DownloadQueueView.
/// </summary>
[TestMethod, ManualTest]
public void Show_DownloadQueueView()
{
var globalBrowserData = new GlobalBrowserData();
var viewModel = new DownloadQueueViewModel(globalBrowserData.DownloadItemModels);
this.CreateDummyOperations(viewModel.DownloadItemModels, viewModel.OnPauseDownloadCalled);
var view = new DownloadQueueView { DataContext = viewModel };
WindowFactory.CreateAndShow(view);
}
/// <summary>
/// The CreateDummyOperations.
/// </summary>
/// <param name="operations">The operations<see cref="ObservableCollection{OperationModel}"/>.</param>
/// <param name="pauseDownloadAction">The pauseDownloadAction<see cref="ICommand"/>.</param>
private void CreateDummyOperations(ObservableCollection<DownloadItemModel> operations, Action<DownloadItemModel> pauseDownloadAction)
{
var random = new Random();
for (var i = 0; i < 10; i++)
{
var operation = new DummyOperation() { Status = (OperationStatus)(i % 6) };
var operationModel = new OperationModel(operation) { PauseDownloadAction = pauseDownloadAction, IsQueuedControlsVisible = (i & 1) == 1 };
var progress = TestHelper.GetRandomLong(0, 100);
operation.Duration = TestHelper.GetRandomLong(10, 10000);
operation.FileSize = TestHelper.GetRandomLong(10000, 10000000000);
operation.Input = $"https://youtube.com/view={i}";
operation.Link = $"https://youtube.com/link={i}"; ;
operation.Output = $@"C:\Users\YoutubeUser\File{TestHelper.GetRandomLong(100, 10000)}.mp4";
operation.Progress = progress;
operation.ProgressPercentage = (int)progress;
operation.ProgressText = $"{progress}%";
operation.ReportsProgress = true;
operation.Speed = $"{TestHelper.GetRandomInt(10, 100)}MB/s";
operation.Status = (OperationStatus)(i % 6);
operation.Thumbnail = null;
operation.Title = $"Youtube Title Movie Number {i}";
operations.Add(operationModel);
}
}
#endregion Methods
}
}

View File

@@ -0,0 +1,30 @@
namespace VideoBrowser.Test.Views
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VideoBrowser.Controls.CefSharpBrowser.ViewModels;
using VideoBrowser.Controls.CefSharpBrowser.Views;
using VideoBrowser.Test.Common;
using VideoBrowser.Test.TestHelpers;
/// <summary>
/// Defines the <see cref="SettingsViewTest" />.
/// </summary>
[TestClass]
public class SettingsViewTest
{
#region Methods
/// <summary>
/// The Show_SettingsView.
/// </summary>
[TestMethod, ManualTest]
public void Show_SettingsView()
{
var viewModel = new SettingsViewModel();
var view = new SettingsView { DataContext = viewModel };
WindowFactory.CreateAndShow(view);
}
#endregion Methods
}
}

View File

@@ -0,0 +1,38 @@
namespace VideoBrowser.Test.Views
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Windows.Controls;
using VideoBrowser.Controls.CefSharpBrowser.ViewModels;
using VideoBrowser.Core;
using VideoBrowser.Test.Common;
using VideoBrowser.Test.TestHelpers;
using VideoBrowser.ViewModels;
using VideoBrowser.Views;
/// <summary>
/// Defines the <see cref="UrlEditorViewTest" />.
/// </summary>
[TestClass]
public class UrlEditorViewTest
{
#region Methods
/// <summary>
/// The Show_UrlEditorView.
/// </summary>
[TestMethod, ManualTest]
public void Show_UrlEditorView()
{
var urlReader = new UrlReader();
var settings = new SettingsViewModel();
var viewModelA = new UrlEditorViewModel(urlReader, settings) { IsVisible = true, FileName = "Youtube Video File Name", FileSize = "5 MB", Duration = "00:02:45" };
var viewModelB = new UrlEditorViewModel(urlReader, settings) { IsVisible = true, FileName = "Youtube Video File Name", FileSize = "1.4 MB", Duration = "00:02:45", IsBusy = true };
var stackPanel = new StackPanel();
stackPanel.Children.Add(new UrlEditorView { DataContext = viewModelA });
stackPanel.Children.Add(new UrlEditorView { DataContext = viewModelB });
WindowFactory.CreateAndShow(stackPanel);
}
#endregion Methods
}
}

BIN
VideoBrowser.Test/key.snk Normal file

Binary file not shown.