Skip to content

Commit fe44d36

Browse files
committed
Fix Tests
1 parent c3e42d7 commit fe44d36

File tree

2 files changed

+48
-27
lines changed

2 files changed

+48
-27
lines changed

RDMSharp/RDM/Slot.cs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,37 +91,24 @@ public Slot(
9191
{
9292
}
9393

94-
#if DEBUG
95-
public
96-
#else
97-
internal
98-
#endif
99-
void UpdateSlotInfo(RDMSlotInfo slotInfo)
94+
internal void UpdateSlotInfo(RDMSlotInfo slotInfo)
10095
{
10196
if (this.SlotId != slotInfo.SlotOffset)
10297
throw new InvalidOperationException($"The given {nameof(slotInfo)} has not the expected id of {this.SlotId} but {slotInfo.SlotOffset}");
10398

10499
this.Type = slotInfo.SlotType;
105100
this.Category = slotInfo.SlotLabelId;
106101
}
107-
#if DEBUG
108-
public
109-
#else
110-
internal
111-
#endif
112-
void UpdateSlotDescription(RDMSlotDescription slotDescription)
102+
103+
internal void UpdateSlotDescription(RDMSlotDescription slotDescription)
113104
{
114105
if (this.SlotId != slotDescription.SlotId)
115106
throw new InvalidOperationException($"The given {nameof(slotDescription)} has not the expected id of {this.SlotId} but {slotDescription.SlotId}");
116107

117108
this.Description = slotDescription.Description;
118109
}
119-
#if DEBUG
120-
public
121-
#else
122-
internal
123-
#endif
124-
void UpdateSlotDefaultValue(RDMDefaultSlotValue defaultSlotValue)
110+
111+
internal void UpdateSlotDefaultValue(RDMDefaultSlotValue defaultSlotValue)
125112
{
126113
if (this.SlotId != defaultSlotValue.SlotOffset)
127114
throw new InvalidOperationException($"The given {nameof(defaultSlotValue)} has not the expected id of {this.SlotId} but {defaultSlotValue.SlotOffset}");

RDMSharpTests/TestManyObjects.cs

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Concurrent;
2+
using System.Reflection;
23

34
namespace RDMSharpTests
45
{
@@ -208,17 +209,50 @@ public void TestSlot()
208209
var slot = new Slot(1);
209210
Assert.That(slot.SlotId, Is.EqualTo(1));
210211

212+
MethodInfo updateSlotDefaultValue = slot.GetType().GetMethod("UpdateSlotDefaultValue", BindingFlags.NonPublic | BindingFlags.Instance)!;
213+
MethodInfo updateSlotInfo = slot.GetType().GetMethod("UpdateSlotInfo", BindingFlags.NonPublic | BindingFlags.Instance)!;
214+
MethodInfo updateSlotDescription = slot.GetType().GetMethod("UpdateSlotDescription", BindingFlags.NonPublic | BindingFlags.Instance)!;
211215
Assert.Multiple(() =>
212216
{
213-
Assert.Throws(typeof(InvalidOperationException), () => { slot.UpdateSlotDefaultValue(new RDMDefaultSlotValue(2)); });
214-
Assert.Throws(typeof(InvalidOperationException), () => { slot.UpdateSlotInfo(new RDMSlotInfo(2)); });
215-
Assert.Throws(typeof(InvalidOperationException), () => { slot.UpdateSlotDescription(new RDMSlotDescription(2)); });
217+
Assert.Throws(typeof(InvalidOperationException), () =>
218+
{
219+
try
220+
{
221+
updateSlotDefaultValue.Invoke(slot, new object[] { new RDMDefaultSlotValue(2) });
222+
}
223+
catch (TargetInvocationException t)
224+
{
225+
throw t.InnerException;
226+
}
227+
});
228+
Assert.Throws(typeof(InvalidOperationException), () =>
229+
{
230+
try
231+
{
232+
updateSlotInfo.Invoke(slot, new object[] { new RDMSlotInfo(2) });
233+
}
234+
catch (TargetInvocationException t)
235+
{
236+
throw t.InnerException;
237+
}
238+
});
239+
Assert.Throws(typeof(InvalidOperationException), () =>
240+
{
241+
try
242+
{
243+
updateSlotDescription.Invoke(slot, new object[] { new RDMSlotDescription(2) });
244+
}
245+
catch (TargetInvocationException t)
246+
{
247+
throw t.InnerException;
248+
}
249+
});
216250
});
217251
Assert.Multiple(() =>
218252
{
219-
Assert.DoesNotThrow(() => { slot.UpdateSlotDefaultValue(new RDMDefaultSlotValue(1, 200)); });
220-
Assert.DoesNotThrow(() => { slot.UpdateSlotInfo(new RDMSlotInfo(1, ERDM_SlotType.SEC_TIMING, ERDM_SlotCategory.CIE_X)); });
221-
Assert.DoesNotThrow(() => { slot.UpdateSlotDescription(new RDMSlotDescription(1, "rrrr")); });
253+
Assert.DoesNotThrow(() => { updateSlotDefaultValue.Invoke(slot, new object[] { new RDMDefaultSlotValue(1, 200) }); });
254+
Assert.DoesNotThrow(() => { updateSlotInfo.Invoke(slot, new object[] { new RDMSlotInfo(1, ERDM_SlotType.SEC_TIMING, ERDM_SlotCategory.CIE_X) }); });
255+
Assert.DoesNotThrow(() => { updateSlotDescription.Invoke(slot, new object[] { new RDMSlotDescription(1, "rrrr") }); });
222256
Assert.That(slot.DefaultValue, Is.EqualTo(200));
223257
Assert.That(slot.Type, Is.EqualTo(ERDM_SlotType.SEC_TIMING));
224258
Assert.That(slot.Category, Is.EqualTo(ERDM_SlotCategory.CIE_X));
@@ -230,9 +264,9 @@ public void TestSlot()
230264
{
231265
Assert.Multiple(() =>
232266
{
233-
Assert.DoesNotThrow(() => { slot.UpdateSlotDefaultValue(new RDMDefaultSlotValue(1, 100)); });
234-
Assert.DoesNotThrow(() => { slot.UpdateSlotInfo(new RDMSlotInfo(1, ERDM_SlotType.PRIMARY, ERDM_SlotCategory.COLOR_SCROLL)); });
235-
Assert.DoesNotThrow(() => { slot.UpdateSlotDescription(new RDMSlotDescription(1, "aaa")); });
267+
Assert.DoesNotThrow(() => { updateSlotDefaultValue.Invoke(slot, new object[] { new RDMDefaultSlotValue(1, 100) }); });
268+
Assert.DoesNotThrow(() => { updateSlotInfo.Invoke(slot, new object[] { new RDMSlotInfo(1, ERDM_SlotType.PRIMARY, ERDM_SlotCategory.COLOR_SCROLL) }); });
269+
Assert.DoesNotThrow(() => { updateSlotDescription.Invoke(slot, new object[] { new RDMSlotDescription(1, "aaa") }); });
236270
Assert.That(fired, Is.EqualTo(4));
237271
Assert.That(slot.DefaultValue, Is.EqualTo(100));
238272
Assert.That(slot.Type, Is.EqualTo(ERDM_SlotType.PRIMARY));

0 commit comments

Comments
 (0)