Skip to content

Commit d9ca4aa

Browse files
authored
Gui2: add missing tests (#167)
* gui2: add missing tests * fixing the detected error * fixed bug in test
1 parent e601b40 commit d9ca4aa

5 files changed

Lines changed: 30 additions & 10 deletions

File tree

.github/workflows/dotnet.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ jobs:
4242
- name: Test
4343
run: |
4444
dotnet test --no-build --verbosity normal Tests\bin\${{ matrix.configuration }}\${{ matrix.dotnet }}*\tests.dll
45+
- name: GUITest
46+
if: matrix.dotnet == 'net8'
47+
run: |
48+
dotnet test --no-build --verbosity normal GUITests\bin\${{ matrix.configuration }}\${{ matrix.dotnet }}*\GUITests.dll
4549
- name: Upload Artifact
4650
uses: actions/upload-artifact@v4
4751
with:

EDSEditorGUI2/ViewModels/DeviceOD.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void AddIndex(int index, string name, LibCanOpen.OdObject.Types.ObjectTyp
4040
var newObj = new OdObject
4141
{
4242
Name = name,
43-
Type = type
43+
ObjectType = type
4444
};
4545

4646
// create OD entry

EDSEditorGUI2/ViewModels/OdObject.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public partial class OdObject : ObservableObject
2222
string _description = string.Empty;
2323

2424
[ObservableProperty]
25-
LibCanOpen.OdObject.Types.ObjectType _type;
25+
LibCanOpen.OdObject.Types.ObjectType _objectType;
2626

2727
[ObservableProperty]
2828
string _countLabel = string.Empty;
@@ -41,13 +41,13 @@ public partial class OdObject : ObservableObject
4141
/// </summary>
4242
public OdSubObject? AddSubEntry(KeyValuePair<string, OdSubObject> selected)
4343
{
44-
if (Type == LibCanOpen.OdObject.Types.ObjectType.Var)
44+
if (ObjectType == LibCanOpen.OdObject.Types.ObjectType.Var)
4545
return null;
4646

4747
OdSubObject newOd;
4848

4949
//Do we need the type check??
50-
if ((SubObjects.Count == 0) && ((Type == LibCanOpen.OdObject.Types.ObjectType.Array) || (Type == LibCanOpen.OdObject.Types.ObjectType.Record)))
50+
if ((SubObjects.Count == 0) && ((ObjectType == LibCanOpen.OdObject.Types.ObjectType.Array) || (ObjectType == LibCanOpen.OdObject.Types.ObjectType.Record)))
5151
{
5252
SubObjects.Add(new KeyValuePair<string, OdSubObject>("0", new OdSubObject
5353
{
@@ -125,7 +125,7 @@ public partial class OdObject : ObservableObject
125125
/// <returns>true on successfull removal</returns>
126126
public bool RemoveSubEntry(KeyValuePair<string, OdSubObject> subObjectToRemove, bool renumber)
127127
{
128-
if (Type == LibCanOpen.OdObject.Types.ObjectType.Array || Type == LibCanOpen.OdObject.Types.ObjectType.Record)
128+
if (ObjectType == LibCanOpen.OdObject.Types.ObjectType.Array || ObjectType == LibCanOpen.OdObject.Types.ObjectType.Record)
129129
{
130130
UInt16 maxSubIndex = SubObjects[0].Value.DefaultValue.ToInteger();
131131
UInt16 lastSubIndex = SubObjects.Last().Key.ToInteger();

GUITests/MappingTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using EDSEditorGUI2.Mapper;
2+
using LibCanOpen;
3+
4+
namespace GUITests
5+
{
6+
public class MappingTests
7+
{
8+
[Fact]
9+
public void MappingFromProtobuffer()
10+
{
11+
// testing for exception in the mapping assert.
12+
var sut = new CanOpenDevice();
13+
ProtobufferViewModelMapper.MapFromProtobuffer(sut);
14+
}
15+
}
16+
}

GUITests/ViewModels_OdObjects.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public ViewModels_OdObjects()
4141
public void AddSubEntry_VarType()
4242
{
4343
sut = new OdObject();
44-
sut.Type = LibCanOpen.OdObject.Types.ObjectType.Var;
44+
sut.ObjectType = LibCanOpen.OdObject.Types.ObjectType.Var;
4545
sut.SubObjects.Add(new KeyValuePair<string, OdSubObject>("0", new OdSubObject
4646
{
4747
Name = "variableTest",
@@ -58,7 +58,7 @@ public void AddSubEntry_VarType()
5858
[Fact]
5959
public void AddSubEntry_RecordType()
6060
{
61-
sut.Type = LibCanOpen.OdObject.Types.ObjectType.Record;
61+
sut.ObjectType = LibCanOpen.OdObject.Types.ObjectType.Record;
6262
sut.AddSubEntry(sut.SubObjects[1]);
6363
Assert.Equal(4, sut.SubObjects.Count);
6464
Assert.Equal("0x03", sut.SubObjects[0].Value.DefaultValue);
@@ -70,7 +70,7 @@ public void AddSubEntry_RecordType()
7070
public void RemoveSubEntry_VarType(bool renumber)
7171
{
7272
sut = new OdObject();
73-
sut.Type = LibCanOpen.OdObject.Types.ObjectType.Var;
73+
sut.ObjectType = LibCanOpen.OdObject.Types.ObjectType.Var;
7474
sut.SubObjects.Add(new KeyValuePair<string, OdSubObject>("0x01", new OdSubObject
7575
{
7676
Name = "variableTest",
@@ -88,7 +88,7 @@ public void RemoveSubEntry_VarType(bool renumber)
8888
public void RemoveSubEntry_RecordType()
8989
{
9090
sut = new OdObject();
91-
sut.Type = LibCanOpen.OdObject.Types.ObjectType.Record;
91+
sut.ObjectType = LibCanOpen.OdObject.Types.ObjectType.Record;
9292
sut.SubObjects.Add(new KeyValuePair<string, OdSubObject>("0x00", new OdSubObject
9393
{
9494
Name = "variableTest0",
@@ -118,7 +118,7 @@ public void RemoveSubEntry_RecordType()
118118
}));
119119

120120
var result = sut.RemoveSubEntry(sut.SubObjects[1], false);
121-
Assert.False(result);
121+
Assert.True(result);
122122
}
123123
}
124124
}

0 commit comments

Comments
 (0)