-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathInventoryProcessDataTests.cs
More file actions
65 lines (55 loc) · 2.08 KB
/
InventoryProcessDataTests.cs
File metadata and controls
65 lines (55 loc) · 2.08 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
using System;
using System.Collections.Generic;
using ByteSync.Business.Inventories;
using ByteSync.Models.Inventories;
using FluentAssertions;
using NUnit.Framework;
namespace ByteSync.Client.UnitTests.Business.Inventories;
[TestFixture]
public class InventoryProcessDataTests
{
[Test]
public void SetError_ShouldUpdateLastException_AndRaiseEvent()
{
// Arrange
var data = new InventoryProcessData();
var values = new List<bool>();
data.ErrorEvent.Subscribe(values.Add);
var exception = new InvalidOperationException("boom");
// Act
data.SetError(exception);
// Assert
data.LastException.Should().Be(exception);
values.Should().Contain(true);
}
[Test]
public void RecordSkippedEntry_ShouldUpdateGlobalAndReasonCounters()
{
// Arrange
var data = new InventoryProcessData();
// Act
data.RecordSkippedEntry(new SkippedEntry { Reason = SkipReason.Hidden });
data.RecordSkippedEntry(new SkippedEntry { Reason = SkipReason.Hidden });
data.RecordSkippedEntry(new SkippedEntry { Reason = SkipReason.NoiseEntry });
// Assert
data.SkippedCount.Should().Be(3);
data.GetSkippedCountByReason(SkipReason.Hidden).Should().Be(2);
data.GetSkippedCountByReason(SkipReason.NoiseEntry).Should().Be(1);
data.GetSkippedCountByReason(SkipReason.Offline).Should().Be(0);
}
[Test]
public void Reset_ShouldClearSkippedEntriesAndCounters()
{
// Arrange
var data = new InventoryProcessData();
data.RecordSkippedEntry(new SkippedEntry { Reason = SkipReason.Hidden });
data.RecordSkippedEntry(new SkippedEntry { Reason = SkipReason.NoiseEntry });
// Act
data.Reset();
// Assert
data.SkippedEntries.Should().BeEmpty();
data.SkippedCount.Should().Be(0);
data.GetSkippedCountByReason(SkipReason.Hidden).Should().Be(0);
data.GetSkippedCountByReason(SkipReason.NoiseEntry).Should().Be(0);
}
}