Refrest test project
This commit is contained in:
@@ -3,10 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.2.32630.192
|
VisualStudioVersion = 17.2.32630.192
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgwProxy.Gomba.Test", "EgwProxy.Gomba.Test\EgwProxy.Gomba.Test.csproj", "{2B7F1536-61D1-4F05-AF8D-62A52D114479}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgwProxy.Gomba", "EgwProxy.Gomba\EgwProxy.Gomba.csproj", "{CC377124-1B94-40C1-B552-D6D42EB2BF27}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgwProxy.Emmegi", "EgwProxy.Emmegi\EgwProxy.Emmegi.csproj", "{F3C0F746-B4FB-4CBB-92BD-9C9A686A21BB}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgwProxy.Emmegi", "EgwProxy.Emmegi\EgwProxy.Emmegi.csproj", "{F3C0F746-B4FB-4CBB-92BD-9C9A686A21BB}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgwProxy.Emmegi.Test", "EgwProxy.Emmegi.Test\EgwProxy.Emmegi.Test.csproj", "{A5DDEF7B-98C3-4391-B8BC-16CFC469B77E}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgwProxy.Emmegi.Test", "EgwProxy.Emmegi.Test\EgwProxy.Emmegi.Test.csproj", "{A5DDEF7B-98C3-4391-B8BC-16CFC469B77E}"
|
||||||
@@ -17,14 +13,6 @@ Global
|
|||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{2B7F1536-61D1-4F05-AF8D-62A52D114479}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{2B7F1536-61D1-4F05-AF8D-62A52D114479}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{2B7F1536-61D1-4F05-AF8D-62A52D114479}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{2B7F1536-61D1-4F05-AF8D-62A52D114479}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{CC377124-1B94-40C1-B552-D6D42EB2BF27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{CC377124-1B94-40C1-B552-D6D42EB2BF27}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{CC377124-1B94-40C1-B552-D6D42EB2BF27}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{CC377124-1B94-40C1-B552-D6D42EB2BF27}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{F3C0F746-B4FB-4CBB-92BD-9C9A686A21BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{F3C0F746-B4FB-4CBB-92BD-9C9A686A21BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{F3C0F746-B4FB-4CBB-92BD-9C9A686A21BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{F3C0F746-B4FB-4CBB-92BD-9C9A686A21BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{F3C0F746-B4FB-4CBB-92BD-9C9A686A21BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{F3C0F746-B4FB-4CBB-92BD-9C9A686A21BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
|||||||
@@ -54,6 +54,15 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
<None Include="conf\.placeholder" />
|
<None Include="conf\.placeholder" />
|
||||||
|
<None Include="conf\testSetup_73.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="conf\testSetup_72.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="conf\testSetup_71.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Include="conf\testSetup.json">
|
<None Include="conf\testSetup.json">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using EgwProxy.Shelly.Clients;
|
using EgwProxy.Shelly.Clients;
|
||||||
@@ -44,10 +41,15 @@ namespace EgwProxy.Shelly.Test
|
|||||||
return answ;
|
return answ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////APC
|
||||||
|
//private string shellyAddr = "10.74.81.71";
|
||||||
//// caffè
|
//// caffè
|
||||||
//private string shellyAddr = "10.74.81.72";
|
//private string shellyAddr = "10.74.81.72";
|
||||||
//APC
|
//private string model = "Pm1";
|
||||||
private string shellyAddr = "10.74.81.71";
|
|
||||||
|
////3EM Trifase
|
||||||
|
//private string shellyAddr = "10.74.81.73";
|
||||||
|
//private string model = "Pro3Em";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Programma principale
|
/// Programma principale
|
||||||
@@ -60,7 +62,7 @@ namespace EgwProxy.Shelly.Test
|
|||||||
Console.WriteLine(separator);
|
Console.WriteLine(separator);
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
||||||
string BaseDirectory = System.IO.Path.GetDirectoryName(exePath);
|
string BaseDirectory = Path.GetDirectoryName(exePath);
|
||||||
string testFile = Path.Combine(BaseDirectory, "conf", ReadSetting("testFile"));
|
string testFile = Path.Combine(BaseDirectory, "conf", ReadSetting("testFile"));
|
||||||
if (!string.IsNullOrEmpty(testFile))
|
if (!string.IsNullOrEmpty(testFile))
|
||||||
{
|
{
|
||||||
@@ -86,9 +88,25 @@ namespace EgwProxy.Shelly.Test
|
|||||||
DefaultTimeout = TimeSpan.FromSeconds(testConf.tOutSec),
|
DefaultTimeout = TimeSpan.FromSeconds(testConf.tOutSec),
|
||||||
ServerUri = new Uri($"http://{testConf.devAddr}/rpc")
|
ServerUri = new Uri($"http://{testConf.devAddr}/rpc")
|
||||||
};
|
};
|
||||||
Shelly1PmClient shelly = new Shelly1PmClient(new HttpClient(), options);
|
Shelly1PmClient shelly1PM = new Shelly1PmClient(new HttpClient(), options);
|
||||||
// test chiamata completa
|
ShellyPro3EmClient shellyPro3 = new ShellyPro3EmClient(new HttpClient(), options);
|
||||||
serverTest(shelly);
|
switch (testConf.model)
|
||||||
|
{
|
||||||
|
case shellyModel.nd:
|
||||||
|
break;
|
||||||
|
case shellyModel.gen1:
|
||||||
|
// test chiamata completa
|
||||||
|
serverTest(shelly1PM);
|
||||||
|
break;
|
||||||
|
case shellyModel.gen2:
|
||||||
|
// test chiamata completa
|
||||||
|
serverTest(shellyPro3);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool doRepeat = true;
|
bool doRepeat = true;
|
||||||
while (doRepeat)
|
while (doRepeat)
|
||||||
{
|
{
|
||||||
@@ -106,25 +124,19 @@ namespace EgwProxy.Shelly.Test
|
|||||||
switch (item.action)
|
switch (item.action)
|
||||||
{
|
{
|
||||||
case stepType.getFullStatus:
|
case stepType.getFullStatus:
|
||||||
var respFull = Task.Run(() => shelly.GetStatus(CancellationToken.None)).Result;
|
var respFull = Task.Run(() => shelly1PM.GetStatus(CancellationToken.None)).Result;
|
||||||
if (respFull.IsSuccess)
|
if (respFull.IsSuccess)
|
||||||
{
|
{
|
||||||
esitoStep = JsonConvert.SerializeObject(respFull.Value, Formatting.Indented);
|
string serValFull = JsonConvert.SerializeObject(respFull.Value, Formatting.Indented);
|
||||||
}
|
esitoStep = respFull.IsSuccess ? serValFull : "Errore in GetStatus";
|
||||||
else
|
|
||||||
{
|
|
||||||
esitoStep = "Errore in GetStatus";
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case stepType.getSwitchStatus:
|
case stepType.getSwitchStatus:
|
||||||
var respSwitch = Task.Run(() => shelly.GetSwitchStatus(CancellationToken.None, 0)).Result;
|
var respSwitch = Task.Run(() => shellyPro3.GetEmStatus(CancellationToken.None)).Result;
|
||||||
if (respSwitch.IsSuccess)
|
if (respSwitch.IsSuccess)
|
||||||
{
|
{
|
||||||
esitoStep = JsonConvert.SerializeObject(respSwitch.Value, Formatting.Indented);
|
string serValSwitch = JsonConvert.SerializeObject(respSwitch.Value, Formatting.Indented);
|
||||||
}
|
esitoStep = respSwitch.IsSuccess ? serValSwitch : "Errore in GetEmStatus";
|
||||||
else
|
|
||||||
{
|
|
||||||
esitoStep = "Errore in GetSwitchStatus";
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -157,17 +169,40 @@ namespace EgwProxy.Shelly.Test
|
|||||||
// registro ed eseguo chiamata in modalità sincrona
|
// registro ed eseguo chiamata in modalità sincrona
|
||||||
sw.Restart();
|
sw.Restart();
|
||||||
var response = Task.Run(() => shellyClient.GetStatus(CancellationToken.None)).Result;
|
var response = Task.Run(() => shellyClient.GetStatus(CancellationToken.None)).Result;
|
||||||
sw.Stop();
|
if (response.IsSuccess)
|
||||||
Console.WriteLine($"CallSuccess: {response.IsSuccess}");
|
{
|
||||||
if (response.Value != null)
|
string serVal = JsonConvert.SerializeObject(response.Value, Formatting.Indented);
|
||||||
|
sw.Stop();
|
||||||
|
writeResult(response.IsSuccess, serVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void writeResult(bool isSuccess, string serVal)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"CallSuccess: {isSuccess}");
|
||||||
|
if (!string.IsNullOrEmpty(serVal))
|
||||||
{
|
{
|
||||||
Console.WriteLine(separator);
|
Console.WriteLine(separator);
|
||||||
Console.WriteLine(JsonConvert.SerializeObject(response.Value, Formatting.Indented));
|
Console.WriteLine(serVal);
|
||||||
Console.WriteLine(separator);
|
Console.WriteLine(separator);
|
||||||
Console.WriteLine($"Elapsed: {sw.Elapsed.TotalMilliseconds:N3}ms");
|
Console.WriteLine($"Elapsed: {sw.Elapsed.TotalMilliseconds:N3}ms");
|
||||||
Console.WriteLine(separator);
|
Console.WriteLine(separator);
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void serverTest(ShellyPro3EmClient shellyClient)
|
||||||
|
{
|
||||||
|
Console.WriteLine(separator);
|
||||||
|
// registro ed eseguo chiamata in modalità sincrona
|
||||||
|
sw.Restart();
|
||||||
|
var response = Task.Run(() => shellyClient.GetStatus(CancellationToken.None)).Result;
|
||||||
|
if (response.IsSuccess)
|
||||||
|
{
|
||||||
|
string serVal = JsonConvert.SerializeObject(response.Value, Formatting.Indented);
|
||||||
|
sw.Stop();
|
||||||
|
writeResult(response.IsSuccess, serVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace EgwProxy.Shelly.Test
|
|||||||
public class TestSetup
|
public class TestSetup
|
||||||
{
|
{
|
||||||
public string devAddr { get; set; } = "";
|
public string devAddr { get; set; } = "";
|
||||||
|
public shellyModel model { get; set; } = shellyModel.nd;
|
||||||
public int tOutSec{ get; set; } = 5;
|
public int tOutSec{ get; set; } = 5;
|
||||||
public List<singleStep> steps { get; set; }
|
public List<singleStep> steps { get; set; }
|
||||||
}
|
}
|
||||||
@@ -33,4 +34,11 @@ namespace EgwProxy.Shelly.Test
|
|||||||
getSwitchStatus
|
getSwitchStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum shellyModel
|
||||||
|
{
|
||||||
|
nd,
|
||||||
|
gen1,
|
||||||
|
gen2
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"devAddr": "10.74.81.71",
|
"devAddr": "10.74.81.73",
|
||||||
|
"model": "gen2",
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
{
|
||||||
"id": "01",
|
"id": "01",
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"devAddr": "10.74.81.71",
|
||||||
|
"model": "gen1",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"id": "01",
|
||||||
|
"description": "Test SwitchStatus",
|
||||||
|
"action": "getSwitchStatus",
|
||||||
|
"numRep": 5,
|
||||||
|
"waitTime": 500,
|
||||||
|
"paramList": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"devAddr": "10.74.81.72",
|
||||||
|
"model": "gen1",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"id": "01",
|
||||||
|
"description": "Test SwitchStatus",
|
||||||
|
"action": "getSwitchStatus",
|
||||||
|
"numRep": 5,
|
||||||
|
"waitTime": 500,
|
||||||
|
"paramList": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"devAddr": "10.74.81.73",
|
||||||
|
"model": "gen2",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"id": "01",
|
||||||
|
"description": "Test SwitchStatus",
|
||||||
|
"action": "getSwitchStatus",
|
||||||
|
"numRep": 5,
|
||||||
|
"waitTime": 500,
|
||||||
|
"paramList": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user