Vda5050ProtocolServiceTerminalLocationActionResolutionTests.cs
3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System.Reflection;
using Rcs.Domain.Entities;
using Rcs.Domain.Enums;
using Rcs.Infrastructure.Services.Protocol;
using Xunit;
namespace Rcs.Infrastructure.Tests;
public class Vda5050ProtocolServiceTerminalLocationActionResolutionTests
{
private static readonly MethodInfo ResolveTerminalLocationActionIdsMethod =
typeof(Vda5050ProtocolService).GetMethod(
"ResolveTerminalLocationActionIds",
BindingFlags.NonPublic | BindingFlags.Static)!;
[Fact]
public void ResolveTerminalLocationActionIds_ReturnsPickupActionIds_WhenTaskSubTypeIsPick()
{
var pickupApplyId = Guid.NewGuid();
var pickupCompleteId = Guid.NewGuid();
var locationType = new StorageLocationType
{
PickupApplyRequestConfigId = pickupApplyId,
PickupCompleteRequestConfigId = pickupCompleteId
};
var result = InvokeResolveTerminalLocationActionIds(locationType, TaskSubType.Pick);
Assert.NotNull(result);
Assert.Equal(pickupApplyId, result.Value.ApplyActionId);
Assert.Equal(pickupCompleteId, result.Value.CompleteActionId);
}
[Fact]
public void ResolveTerminalLocationActionIds_ReturnsDropActionIds_WhenTaskSubTypeIsDown()
{
var dropApplyId = Guid.NewGuid();
var dropCompleteId = Guid.NewGuid();
var locationType = new StorageLocationType
{
DropApplyRequestConfigId = dropApplyId,
DropCompleteRequestConfigId = dropCompleteId
};
var result = InvokeResolveTerminalLocationActionIds(locationType, TaskSubType.Down);
Assert.NotNull(result);
Assert.Equal(dropApplyId, result.Value.ApplyActionId);
Assert.Equal(dropCompleteId, result.Value.CompleteActionId);
}
[Fact]
public void ResolveTerminalLocationActionIds_ReturnsNull_WhenTaskSubTypeIsMove()
{
var locationType = new StorageLocationType
{
PickupApplyRequestConfigId = Guid.NewGuid(),
PickupCompleteRequestConfigId = Guid.NewGuid(),
DropApplyRequestConfigId = Guid.NewGuid(),
DropCompleteRequestConfigId = Guid.NewGuid()
};
var result = InvokeResolveTerminalLocationActionIds(locationType, TaskSubType.Move);
Assert.Null(result);
}
[Fact]
public void ResolveTerminalLocationActionIds_ReturnsNull_WhenTaskSubTypeIsNull()
{
var locationType = new StorageLocationType
{
PickupApplyRequestConfigId = Guid.NewGuid(),
PickupCompleteRequestConfigId = Guid.NewGuid()
};
var result = InvokeResolveTerminalLocationActionIds(locationType, null);
Assert.Null(result);
}
[Fact]
public void ResolveTerminalLocationActionIds_ReturnsNull_WhenLocationTypeIsNull()
{
var result = InvokeResolveTerminalLocationActionIds(null, TaskSubType.Pick);
Assert.Null(result);
}
[Fact]
public void ResolveTerminalLocationActionIds_ReturnsNull_WhenBothActionIdsAreEmpty()
{
var result = InvokeResolveTerminalLocationActionIds(new StorageLocationType(), TaskSubType.Pick);
Assert.Null(result);
}
private static (Guid? ApplyActionId, Guid? CompleteActionId)? InvokeResolveTerminalLocationActionIds(
StorageLocationType? locationType,
TaskSubType? taskSubType)
{
var value = ResolveTerminalLocationActionIdsMethod.Invoke(
null,
new object?[] { locationType, taskSubType });
if (value == null)
{
return null;
}
var tuple = Assert.IsType<ValueTuple<Guid?, Guid?>>(value);
return (tuple.Item1, tuple.Item2);
}
}