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
|
||||
VisualStudioVersion = 17.2.32630.192
|
||||
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}"
|
||||
EndProject
|
||||
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
|
||||
EndGlobalSection
|
||||
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.Build.0 = Debug|Any CPU
|
||||
{F3C0F746-B4FB-4CBB-92BD-9C9A686A21BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
||||
@@ -54,6 +54,15 @@
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<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">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using EgwProxy.Shelly.Clients;
|
||||
@@ -44,10 +41,15 @@ namespace EgwProxy.Shelly.Test
|
||||
return answ;
|
||||
}
|
||||
|
||||
////APC
|
||||
//private string shellyAddr = "10.74.81.71";
|
||||
//// caffè
|
||||
//private string shellyAddr = "10.74.81.72";
|
||||
//APC
|
||||
private string shellyAddr = "10.74.81.71";
|
||||
//private string model = "Pm1";
|
||||
|
||||
////3EM Trifase
|
||||
//private string shellyAddr = "10.74.81.73";
|
||||
//private string model = "Pro3Em";
|
||||
|
||||
/// <summary>
|
||||
/// Programma principale
|
||||
@@ -60,7 +62,7 @@ namespace EgwProxy.Shelly.Test
|
||||
Console.WriteLine(separator);
|
||||
Console.WriteLine();
|
||||
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"));
|
||||
if (!string.IsNullOrEmpty(testFile))
|
||||
{
|
||||
@@ -86,9 +88,25 @@ namespace EgwProxy.Shelly.Test
|
||||
DefaultTimeout = TimeSpan.FromSeconds(testConf.tOutSec),
|
||||
ServerUri = new Uri($"http://{testConf.devAddr}/rpc")
|
||||
};
|
||||
Shelly1PmClient shelly = new Shelly1PmClient(new HttpClient(), options);
|
||||
Shelly1PmClient shelly1PM = new Shelly1PmClient(new HttpClient(), options);
|
||||
ShellyPro3EmClient shellyPro3 = new ShellyPro3EmClient(new HttpClient(), options);
|
||||
switch (testConf.model)
|
||||
{
|
||||
case shellyModel.nd:
|
||||
break;
|
||||
case shellyModel.gen1:
|
||||
// test chiamata completa
|
||||
serverTest(shelly);
|
||||
serverTest(shelly1PM);
|
||||
break;
|
||||
case shellyModel.gen2:
|
||||
// test chiamata completa
|
||||
serverTest(shellyPro3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
bool doRepeat = true;
|
||||
while (doRepeat)
|
||||
{
|
||||
@@ -106,25 +124,19 @@ namespace EgwProxy.Shelly.Test
|
||||
switch (item.action)
|
||||
{
|
||||
case stepType.getFullStatus:
|
||||
var respFull = Task.Run(() => shelly.GetStatus(CancellationToken.None)).Result;
|
||||
var respFull = Task.Run(() => shelly1PM.GetStatus(CancellationToken.None)).Result;
|
||||
if (respFull.IsSuccess)
|
||||
{
|
||||
esitoStep = JsonConvert.SerializeObject(respFull.Value, Formatting.Indented);
|
||||
}
|
||||
else
|
||||
{
|
||||
esitoStep = "Errore in GetStatus";
|
||||
string serValFull = JsonConvert.SerializeObject(respFull.Value, Formatting.Indented);
|
||||
esitoStep = respFull.IsSuccess ? serValFull : "Errore in GetStatus";
|
||||
}
|
||||
break;
|
||||
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)
|
||||
{
|
||||
esitoStep = JsonConvert.SerializeObject(respSwitch.Value, Formatting.Indented);
|
||||
}
|
||||
else
|
||||
{
|
||||
esitoStep = "Errore in GetSwitchStatus";
|
||||
string serValSwitch = JsonConvert.SerializeObject(respSwitch.Value, Formatting.Indented);
|
||||
esitoStep = respSwitch.IsSuccess ? serValSwitch : "Errore in GetEmStatus";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -157,17 +169,40 @@ namespace EgwProxy.Shelly.Test
|
||||
// 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();
|
||||
Console.WriteLine($"CallSuccess: {response.IsSuccess}");
|
||||
if (response.Value != null)
|
||||
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(JsonConvert.SerializeObject(response.Value, Formatting.Indented));
|
||||
Console.WriteLine(serVal);
|
||||
Console.WriteLine(separator);
|
||||
Console.WriteLine($"Elapsed: {sw.Elapsed.TotalMilliseconds:N3}ms");
|
||||
Console.WriteLine(separator);
|
||||
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 string devAddr { get; set; } = "";
|
||||
public shellyModel model { get; set; } = shellyModel.nd;
|
||||
public int tOutSec{ get; set; } = 5;
|
||||
public List<singleStep> steps { get; set; }
|
||||
}
|
||||
@@ -33,4 +34,11 @@ namespace EgwProxy.Shelly.Test
|
||||
getSwitchStatus
|
||||
}
|
||||
|
||||
public enum shellyModel
|
||||
{
|
||||
nd,
|
||||
gen1,
|
||||
gen2
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"devAddr": "10.74.81.71",
|
||||
"devAddr": "10.74.81.73",
|
||||
"model": "gen2",
|
||||
"steps": [
|
||||
{
|
||||
"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