-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
577 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("az_appservice_dotnet.Test")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("az_appservice_dotnet.Test")] | ||
[assembly: AssemblyCopyright("Copyright © 2023")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("D85D944B-8861-4C3E-979B-F7C227CF2F19")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace az_appservice_dotnet.Test | ||
{ | ||
public class Tests | ||
{ | ||
[Fact] | ||
public void Test1() | ||
{ | ||
Assert.True(true); | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
az-appservice-dotnet.Test/az-appservice-dotnet.Test.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.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>{D85D944B-8861-4C3E-979B-F7C227CF2F19}</ProjectGuid> | ||
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>az_appservice_dotnet.Test</RootNamespace> | ||
<AssemblyName>az_appservice_dotnet.Test</AssemblyName> | ||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<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' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System"/> | ||
<Reference Include="System.Core"/> | ||
<Reference Include="System.Data"/> | ||
<Reference Include="System.Xml"/> | ||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c"> | ||
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath> | ||
</Reference> | ||
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c"> | ||
<HintPath>..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath> | ||
</Reference> | ||
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c"> | ||
<HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c"> | ||
<HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Tests.cs"/> | ||
<Compile Include="Properties\AssemblyInfo.cs"/> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="xunit" version="2.1.0" targetFramework="net45" /> | ||
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" /> | ||
<package id="xunit.assert" version="2.1.0" targetFramework="net45" /> | ||
<package id="xunit.core" version="2.1.0" targetFramework="net45" /> | ||
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net45" /> | ||
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net45" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=appservice/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
39 changes: 39 additions & 0 deletions
39
az-appservice-dotnet.xUnit/models/v1/LongRunningWorkloads/Progress.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
namespace az_appservice_dotnet.xUnit.models.v1.LongRunningWorkloads; | ||
|
||
public class Progress | ||
{ | ||
[Fact] | ||
public void Progress_shouldReturnZeroOnInit() | ||
{ | ||
// Arrange | ||
var sut = new az_appservice_dotnet.models.v1.LongRunningWorkloads(10); | ||
// Act | ||
var actual = sut.Progress; | ||
// Assert | ||
Assert.Equal(0U, actual); | ||
} | ||
|
||
[Fact] | ||
public void Progress_shouldReturn10OnNext() | ||
{ | ||
// Arrange | ||
var sut = new az_appservice_dotnet.models.v1.LongRunningWorkloads(10); | ||
// Act | ||
sut.Next(1); | ||
var actual = sut.Progress; | ||
// Assert | ||
Assert.Equal(10U, actual); | ||
} | ||
|
||
[Fact] | ||
public void Progress_shouldReturn100OnOverflow() | ||
{ | ||
// Arrange | ||
var sut = new az_appservice_dotnet.models.v1.LongRunningWorkloads(10); | ||
// Act | ||
sut.Next(11); | ||
var actual = sut.Progress; | ||
// Assert | ||
Assert.Equal(100U, actual); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
az-appservice-dotnet.xUnit/services/v1/LongRunningTasksService/GetLongRunningTaskProgress.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using az_appservice_dotnet.models; | ||
using az_appservice_dotnet.services; | ||
using Moq; | ||
|
||
namespace az_appservice_dotnet.xUnit.services.v1.LongRunningTasksService; | ||
|
||
public class GetLongRunningTaskProgress | ||
{ | ||
readonly Mock<ILongRunningWorkload> _fakeWorkload = new(); | ||
readonly Mock<ILongRunningWorkloadFactory> _fakeFactory = new(); | ||
|
||
public GetLongRunningTaskProgress() | ||
{ | ||
_fakeFactory.Setup(x => | ||
x.Create(It.IsAny<uint>())).Returns(_fakeWorkload.Object); | ||
} | ||
|
||
[Fact] | ||
public void GetLongRunningTaskProgress_shouldReturnMinus1() | ||
{ | ||
var stubFactory = new Mock<ILongRunningWorkloadFactory>(); | ||
var sut = new az_appservice_dotnet.services.v1.LongRunningTasksService(stubFactory.Object); | ||
var actual = sut.GetLongRunningTaskProgress(new TaskId()); | ||
Assert.Equal(-1, actual); | ||
} | ||
|
||
[Fact] | ||
public void GetLongRunningTaskProgress_shouldReturnForStartedTask() | ||
{ | ||
// Arrange | ||
var sut = new az_appservice_dotnet.services.v1.LongRunningTasksService(_fakeFactory.Object); | ||
var taskId = sut.StartLongRunningTasksAsync(2); | ||
// Act | ||
var actual = sut.GetLongRunningTaskProgress(taskId); | ||
// Assert | ||
Assert.True(actual >= 0); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
az-appservice-dotnet.xUnit/services/v1/LongRunningTasksService/GetLongRunningTasks.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using az_appservice_dotnet.models; | ||
using Moq; | ||
|
||
namespace az_appservice_dotnet.xUnit.services.v1.LongRunningTasksService; | ||
|
||
public class GetLongRunningTasks | ||
{ | ||
readonly Mock<ILongRunningWorkload> _fakeWorkload = new(); | ||
readonly Mock<ILongRunningWorkloadFactory> _fakeFactory = new(); | ||
|
||
public GetLongRunningTasks() | ||
{ | ||
_fakeFactory.Setup(x => | ||
x.Create(It.IsAny<uint>())).Returns(_fakeWorkload.Object); | ||
} | ||
|
||
[Fact] | ||
public void GetLongRunningTasks_shouldReturnEmptyI() | ||
{ | ||
var stubFactory = new Mock<ILongRunningWorkloadFactory>(); | ||
var sut = new az_appservice_dotnet.services.v1.LongRunningTasksService(stubFactory.Object); | ||
var actual = sut.GetLongRunningTasks(); | ||
Assert.Empty(actual); | ||
} | ||
|
||
[Fact] | ||
public void GetLongRunningTasks_shouldReturnStartedTasks() | ||
{ | ||
// Arrange | ||
var sut = new az_appservice_dotnet.services.v1.LongRunningTasksService(_fakeFactory.Object); | ||
var taskId1 = sut.StartLongRunningTasksAsync(2); | ||
var taskId2 = sut.StartLongRunningTasksAsync(2); | ||
// Act | ||
var actual = sut.GetLongRunningTasks(); | ||
// Assert | ||
Assert.Equal(2, actual.Count); | ||
Assert.Contains(actual, x => x == taskId1); | ||
Assert.Contains(actual, x => x == taskId2); | ||
} | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
az-appservice-dotnet.xUnit/services/v1/LongRunningTasksService/StartLongRunningTasksAsync.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using az_appservice_dotnet.models; | ||
using az_appservice_dotnet.services; | ||
using Moq; | ||
|
||
namespace az_appservice_dotnet.xUnit.services.v1.LongRunningTasksService; | ||
|
||
public class StartLongRunningTasksAsync | ||
{ | ||
readonly Mock<ILongRunningWorkload> _fakeWorkload = new(); | ||
readonly Mock<ILongRunningWorkloadFactory> _fakeFactory = new(); | ||
|
||
public StartLongRunningTasksAsync() | ||
{ | ||
_fakeFactory.Setup(x => | ||
x.Create(It.IsAny<uint>())).Returns(_fakeWorkload.Object); | ||
} | ||
|
||
[Fact] | ||
public void StartLongRunningTasksAsync_shouldReturnTaskId() | ||
{ | ||
// Arrange | ||
var sut = new az_appservice_dotnet.services.v1.LongRunningTasksService(_fakeFactory.Object); | ||
// Act | ||
var actual = sut.StartLongRunningTasksAsync(2); | ||
// Assert | ||
Assert.IsType<TaskId>(actual); | ||
} | ||
|
||
[Fact] | ||
public void StartLongRunningTasksAsync_shouldReturnTaskIdWhatExists() | ||
{ | ||
// Arrange | ||
var sut = new az_appservice_dotnet.services.v1.LongRunningTasksService(_fakeFactory.Object); | ||
// Act | ||
var taskId = sut.StartLongRunningTasksAsync(2); | ||
var foundTaskId = sut.GetLongRunningTaskProgress(taskId); | ||
// Assert | ||
Assert.True(foundTaskId >= 0); | ||
} | ||
|
||
[Fact] | ||
public void StartLongRunningTasksAsync_shouldCallWorkloadNext2Times() | ||
{ | ||
// Arrange | ||
var sut = new az_appservice_dotnet.services.v1.LongRunningTasksService(_fakeFactory.Object); | ||
// Act | ||
sut.StartLongRunningTasksAsync(2); | ||
Thread.Sleep(3000); | ||
// Assert | ||
_fakeWorkload.Verify(wl => wl.Next(It.IsAny<uint>()), | ||
Times.Exactly(2)); | ||
} | ||
|
||
[Fact] | ||
public void StartLongRunningTasksAsync_shouldStartTaskAsIncomplete() | ||
{ | ||
// Arrange | ||
var sut = new az_appservice_dotnet.services.v1.LongRunningTasksService(_fakeFactory.Object); | ||
// Act | ||
var actual = sut.StartLongRunningTasksAsync(1); | ||
// Assert | ||
sut.GetTaskDictionaryTest().TryGetValue(actual, out var task); | ||
Assert.NotNull(task); | ||
Assert.False(task.IsCompleted); | ||
} | ||
|
||
[Fact] | ||
public void StartLongRunningTasksAsync_shouldStartTaskHaveCompleted() | ||
{ | ||
// Arrange | ||
var sut = new az_appservice_dotnet.services.v1.LongRunningTasksService(_fakeFactory.Object); | ||
// Act | ||
var actual = sut.StartLongRunningTasksAsync(1); | ||
Thread.Sleep(2000); | ||
// Assert | ||
sut.GetTaskDictionaryTest().TryGetValue(actual, out var task); | ||
Assert.NotNull(task); | ||
Assert.True(task.IsCompleted); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
az-appservice-dotnet.xUnit/services/v1/LongRunningWorkloadFactory/Create.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace az_appservice_dotnet.xUnit.services.v1.LongRunningWorkloadFactory; | ||
|
||
public class Create | ||
{ | ||
[Fact] | ||
public void Create_shouldReturnLongRunningWorkload() | ||
{ | ||
// Arrange | ||
var sut = new az_appservice_dotnet.models.v1.LongRunningWorkloadFactory(); | ||
// Act | ||
var actual = sut.Create(10); | ||
// Assert | ||
Assert.IsType<az_appservice_dotnet.models.v1.LongRunningWorkloads>(actual); | ||
} | ||
|
||
[Fact] | ||
public void Create_shouldPassDurationToWorkload() | ||
{ | ||
// Arrange | ||
var sut = new az_appservice_dotnet.models.v1.LongRunningWorkloadFactory(); | ||
// Act | ||
var actual = sut.Create(10); | ||
actual.Next(9); | ||
var actualProgress1 = actual.Progress; | ||
actual.Next(10); | ||
var actualProgress2 = actual.Progress; | ||
// Assert | ||
Assert.Equal(90U, actualProgress1); | ||
Assert.Equal(100U, actualProgress2); | ||
} | ||
} |
Oops, something went wrong.