-
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.
Merge pull request #99 from doodz/Develop
[MMS] : Doods : add TU
- Loading branch information
Showing
68 changed files
with
5,896 additions
and
7,613 deletions.
There are no files selected for viewing
254 changes: 254 additions & 0 deletions
254
Doods.Openmediavault.TU/Clients/OmvSystemClientUnitTest.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,254 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Doods.Openmediavault.Mobile.Std.Enums; | ||
using Doods.Openmediavault.Rpc.Std; | ||
using Doods.Openmediavault.Rpc.Std.Clients; | ||
using Doods.Openmediavault.Rpc.std.Data.V4; | ||
using Doods.Openmediavault.Rpc.std.Data.V4.Settings; | ||
using Doods.Openmediavault.Rpc.std.Data.V5; | ||
using Doods.Openmediavault.Rpc.Std.Interfaces; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Moq; | ||
|
||
namespace Doods.Openmediavault.TU.Clients | ||
{ | ||
[TestClass] | ||
public class OMVVersionsUnitTest | ||
{ | ||
[DataTestMethod] | ||
[DataRow("NotFound")] | ||
[DataRow("Ix")] | ||
[DataRow("Omnius")] | ||
[DataRow("Fedaykin")] | ||
[DataRow("Sardaukar")] | ||
[DataRow("Kralizec")] | ||
[DataRow("Stone burner")] | ||
[DataRow("Erasmus")] | ||
[DataRow("Arrakis")] | ||
[DataRow("Usul")] | ||
public void Create(string version) | ||
{ | ||
var v = OMVVersions.GetVersionFromString(version); | ||
Assert.IsNotNull(v); | ||
Assert.AreEqual(version, v.Name); | ||
} | ||
|
||
[TestMethod] | ||
public void NotFound() | ||
{ | ||
var v = OMVVersions.GetVersionFromString("version"); | ||
Assert.IsNotNull(v); | ||
Assert.AreEqual("NotFound", v.Name); | ||
} | ||
|
||
[TestMethod] | ||
public void Version4lowerThan5() | ||
{ | ||
var b = (OMVVersions.Version4 < OMVVersions.Version5); | ||
Assert.IsTrue(b); | ||
} | ||
[TestMethod] | ||
public void Version4UpperThan2() | ||
{ | ||
|
||
var b = (OMVVersions.Version4 > OMVVersions.Version2); | ||
Assert.IsTrue(b); | ||
} | ||
} | ||
|
||
|
||
[TestClass] | ||
public class OmvSystemClientUnitTest | ||
{ | ||
[TestMethod] | ||
public void Create() | ||
{ | ||
var rpcClient = new Mock<IRpcClient>(); | ||
var obj = new OmvSystemClient(rpcClient.Object); | ||
Assert.IsNotNull(obj); | ||
} | ||
[TestMethod] | ||
public async Task GetTimeZoneList() | ||
{ | ||
var rpcClient = new Mock<IRpcClient>(); | ||
//rpcClient.Setup(c => c.ExecuteTaskAsync<It.IsAnyType>()).ReturnsAsync(()=>default); | ||
var obj = new OmvSystemClient(rpcClient.Object); | ||
Assert.IsNotNull(obj); | ||
var result = await obj.GetTimeZoneList(); | ||
Assert.IsNotNull(result); | ||
Assert.AreEqual(0,result.Count()); | ||
} | ||
|
||
[TestMethod] | ||
public async Task GetTimeZoneList2() | ||
{ | ||
var rpcClient = new Mock<IRpcClient>(); | ||
rpcClient.Setup(c => c.ExecuteTaskAsync<IEnumerable<string>>(It.IsAny<IRpcRequest>())) | ||
.ReturnsAsync(new List<string>(){"foo","bar"}); | ||
var obj = new OmvSystemClient(rpcClient.Object); | ||
Assert.IsNotNull(obj); | ||
var result = await obj.GetTimeZoneList(); | ||
Assert.IsNotNull(result); | ||
Assert.AreEqual(2, result.Count()); | ||
} | ||
|
||
[TestMethod] | ||
public async Task GetDateAndTimeSetting() | ||
{ | ||
var rpcClient = new Mock<IRpcClient>(); | ||
rpcClient.Setup(c => c.ExecuteTaskAsync<TimeSetting>(It.IsAny<IRpcRequest>())) | ||
.ReturnsAsync(new TimeSetting()); | ||
var obj = new OmvSystemClient(rpcClient.Object); | ||
Assert.IsNotNull(obj); | ||
var result = await obj.GetDateAndTimeSetting(); | ||
Assert.IsNotNull(result); | ||
} | ||
|
||
[TestMethod] | ||
public async Task SetDateAndTimeSetting() | ||
{ | ||
var rpcClient = new Mock<IRpcClient>(); | ||
var settings = new TimeSetting(); | ||
rpcClient.Setup(c => c.ExecuteTaskAsync<object>(It.IsAny<IRpcRequest>())) | ||
.ReturnsAsync(new object()); | ||
var obj = new OmvSystemClient(rpcClient.Object); | ||
Assert.IsNotNull(obj); | ||
var result = await obj.SetDateAndTimeSetting(settings); | ||
Assert.IsNotNull(result); | ||
} | ||
[TestMethod] | ||
public async Task GetSystemInformationsV4() | ||
{ | ||
var rpcClient = new Mock<IRpcClient>(); | ||
var slt = new List<SystemInformation>(); | ||
|
||
var info = new SystemInformation(); | ||
info.Name = "ts"; | ||
info.Value = (ValueUnion)"1000"; | ||
slt.Add(info); | ||
|
||
info = new SystemInformation(); | ||
info.Name = "System time"; | ||
info.Value = (ValueUnion)"System_time_string"; | ||
slt.Add(info); | ||
|
||
info = new SystemInformation(); | ||
info.Name = "Hostname"; | ||
info.Value = (ValueUnion)"Hostname_string"; | ||
slt.Add(info); | ||
|
||
info = new SystemInformation(); | ||
info.Name = "Version"; | ||
info.Value = (ValueUnion)"Version_string"; | ||
slt.Add(info); | ||
|
||
info = new SystemInformation(); | ||
info.Name = "Processor"; | ||
info.Value = (ValueUnion)"Processor_string"; | ||
slt.Add(info); | ||
|
||
info = new SystemInformation(); | ||
info.Name = "MemTotal"; | ||
info.Value = (ValueUnion)"2000"; | ||
slt.Add(info); | ||
|
||
info = new SystemInformation(); | ||
info.Name = "Kernel"; | ||
info.Value = (ValueUnion)"Kernel_string"; | ||
slt.Add(info); | ||
|
||
info = new SystemInformation(); | ||
info.Name = "Uptime"; | ||
info.Value = (ValueUnion)"Uptime_string"; | ||
slt.Add(info); | ||
|
||
info = new SystemInformation(); | ||
info.Name = "Load average"; | ||
info.Value = (ValueUnion)"Load_average_string"; | ||
slt.Add(info); | ||
|
||
info = new SystemInformation(); | ||
info.Name = "configDirty"; | ||
info.Value = (ValueUnion)"true"; | ||
slt.Add(info); | ||
|
||
info = new SystemInformation(); | ||
info.Name = "rebootRequired"; | ||
info.Value = (ValueUnion)"false"; | ||
slt.Add(info); | ||
|
||
info = new SystemInformation(); | ||
info.Name = "pkgUpdatesAvailable"; | ||
info.Value = (ValueUnion)"true"; | ||
slt.Add(info); | ||
|
||
|
||
//rpcClient.Setup(c => c.ExecuteTaskAsync<IEnumerable<SystemInformation>>(It.IsAny<IRpcRequest>())) | ||
// .ReturnsAsync(slt); | ||
//rpcClient.Setup(c => c.ExecuteTaskAsync<IEnumerable<SystemInformation>>(It.IsAny<IRpcRequest>())) | ||
// .ReturnsAsync(slt); | ||
rpcClient.Setup(c => c.ExecuteTaskAsync<object>(It.Is<IRpcRequest>(t => t.Method == "getInformation"))) | ||
.ReturnsAsync("Arrakis"); | ||
rpcClient.Setup(c => c.ExecuteTaskAsync<IEnumerable<SystemInformation>> (It.IsAny<IRpcRequest>())) | ||
.ReturnsAsync(slt); | ||
|
||
|
||
|
||
//rpcClient.Setup(c => c.ExecuteTaskAsync<object>(It.Is<IRpcRequest>(t => t.Method == "getInformation"))) | ||
// .ReturnsAsync("Arrakis"); | ||
|
||
var obj = new OmvSystemClient(rpcClient.Object); | ||
Assert.IsNotNull(obj); | ||
obj.SetOMVVersion(OMVVersions.Version4); | ||
var result = await obj.GetSystemInformations(); | ||
Assert.IsNotNull(result); | ||
} | ||
|
||
|
||
[TestMethod] | ||
public async Task GetSystemInformationsV5() | ||
{ | ||
var rpcClient = new Mock<IRpcClient>(); | ||
|
||
//rpcClient.Setup(c => c.ExecuteTaskAsync<object>(It.Is<IRpcRequest>(t => t.Method == "getInformation"))) | ||
// .ReturnsAsync("Usul"); | ||
|
||
//rpcClient.SetupSequence(c => c.ExecuteTaskAsync<object>(It.IsAny<IRpcRequest>())) | ||
// .ReturnsAsync("Usul") | ||
// .ReturnsAsync(new OMVInformations()); | ||
|
||
|
||
// rpcClient.Setup(c => c.ExecuteTaskAsync<It.IsSubtype<OMVInformations>(It.Is<IRpcRequest>(t => t.Method == "getInformation"))) | ||
// .ReturnsAsync("Usul"); | ||
|
||
rpcClient.Setup(c => c.ExecuteTaskAsync<object>(It.Is<IRpcRequest>(t => t.Method == "getInformation"))) | ||
.ReturnsAsync("Usul"); | ||
rpcClient.Setup(c => c.ExecuteTaskAsync<OMVInformations>(It.Is<IRpcRequest>(t => t.Method == "getInformation"))) | ||
.ReturnsAsync(new OMVInformations()); | ||
var obj = new OmvSystemClient(rpcClient.Object); | ||
Assert.IsNotNull(obj); | ||
obj.SetOMVVersion(OMVVersions.Version5); | ||
var result = await obj.GetSystemInformations(); | ||
Assert.IsNotNull(result); | ||
} | ||
|
||
|
||
//case "CPU usage": | ||
// obj.CpuUsage = information.Value.ValueClass.Value; | ||
// break; | ||
//case "": | ||
// obj.MemTotal = long.Parse(information.Value.SimpleStringValue); | ||
// break; | ||
//case "Memory usage": | ||
// obj.MemUsed = long.Parse(information.Value.ValueClass.Value.ToString()); | ||
// break; | ||
|
||
|
||
|
||
|
||
} | ||
} |
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,19 @@ | ||
using Doods.Openmediavault.Rpc.std.Data.V4; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Doods.Openmediavault.TU.Data.V5 | ||
{ | ||
[TestClass] | ||
public class IsRunningUnitTest | ||
{ | ||
[TestMethod] | ||
public void Create() | ||
{ | ||
var obj = new IsRunning(); | ||
Assert.IsNotNull(obj); | ||
Assert.IsFalse(obj.Running); | ||
|
||
Assert.IsNull(obj.Filename); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
Doods.Openmediavault.TU/Data/V5/OMVInformationsUnitTest.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,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Doods.Openmediavault.Rpc.std.Data.V5; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Doods.Framework.Ssh.Std.Requests; | ||
using Doods.Framework.Ssh.Std.Serializers; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Moq; | ||
using NuGet.Frameworks; | ||
|
||
namespace Doods.Openmediavault.TU.Data.V5 | ||
{ | ||
[TestClass] | ||
public class OMVInformationsUnitTest | ||
{ | ||
[TestMethod] | ||
public void Create() | ||
{ | ||
var obj = new OMVInformations(); | ||
Assert.IsNotNull(obj); | ||
Assert.IsFalse(obj.LegacyMode); | ||
Assert.AreEqual(default(long),obj.Ts); | ||
Assert.IsNull(obj.Time); | ||
Assert.IsNull(obj.Hostname); | ||
Assert.IsNull(obj.Version); | ||
Assert.IsNull(obj.CpuModelName); | ||
Assert.AreEqual(default(double), obj.CpuUsage); | ||
Assert.AreEqual(default(long), obj.MemTotal); | ||
Assert.AreEqual(default(long), obj.MemUsed); | ||
Assert.IsNull(obj.Kernel); | ||
Assert.IsNull(obj.Uptime); | ||
Assert.IsNull(obj.LoadAverage); | ||
Assert.IsFalse(obj.ConfigDirty); | ||
Assert.IsFalse(obj.RebootRequired); | ||
Assert.IsFalse(obj.PkgUpdatesAvailable); | ||
} | ||
} | ||
} |
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,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" /> | ||
<PackageReference Include="Moq" Version="4.16.1" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" /> | ||
<PackageReference Include="coverlet.collector" Version="3.0.3"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Doods.Openmedivault\Doods.Openmediavault.Mobile.Std\Doods.Openmediavault.Mobile.Std.csproj" /> | ||
<ProjectReference Include="..\Doods.Openmedivault\Doods.Openmediavault.Rpc.std\Doods.Openmediavault.Rpc.Std.csproj" /> | ||
<ProjectReference Include="..\Doods.Openmedivault\Doods.Openmedivault.Http.Std\Doods.Openmedivault.Http.Std.csproj" /> | ||
<ProjectReference Include="..\Doods.Openmedivault\Doods.Openmedivault.Ssh.Std\Doods.Openmedivault.Ssh.Std.csproj" /> | ||
</ItemGroup> | ||
|
||
</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
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
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
Oops, something went wrong.