Skip to content

Commit 6dabe97

Browse files
committed
Fixed error around faulty changes.
1 parent fe9b747 commit 6dabe97

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

DotJEM.Json.Storage.Test/Adapter/Materialize/ChangeLog/StorageChangesCollection.cs

+26
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,32 @@ public void Partitioned_ReturnsChangesPartitionedIntoCreateUpdateDelete()
7070
Assert.That(string.Join(":", changes.Partitioned.Select(change => change.Generation.ToString("D2"))),
7171
Is.EqualTo("01:05:07:11:12:00:02:04:09:13:03:06:08:10:14"));
7272
}
73+
74+
[Test]
75+
public void FaultyChanges()
76+
{
77+
IStorageChangeCollection changes = new StorageChangeCollection("N/A", 0, new List<IChangeLogRow>()
78+
{
79+
new FakeChange(00, ChangeType.Update, Guid.Empty), // 00 -> i=5
80+
new FakeChange(01, ChangeType.Faulty, Guid.Empty), // 01 -> i=0
81+
new FakeChange(02, ChangeType.Update, Guid.Empty), // 02 -> i=6
82+
new FakeChange(03, ChangeType.Delete, Guid.Empty), // 03 -> i=10
83+
new FakeChange(04, ChangeType.Update, Guid.Empty), // 04 -> i=7
84+
new FakeChange(05, ChangeType.Create, Guid.Empty), // 05 -> i=1
85+
new FakeChange(06, ChangeType.Delete, Guid.Empty), // 06 -> i=11
86+
new FakeChange(07, ChangeType.Create, Guid.Empty), // 07 -> i=2
87+
new FakeChange(08, ChangeType.Delete, Guid.Empty), // 08 -> i=12
88+
new FakeChange(09, ChangeType.Update, Guid.Empty), // 09 -> i=8
89+
new FakeChange(10, ChangeType.Faulty, Guid.Empty), // 10 -> i=13
90+
new FakeChange(11, ChangeType.Create, Guid.Empty), // 11 -> i=3
91+
new FakeChange(12, ChangeType.Create, Guid.Empty), // 12 -> i=4
92+
new FakeChange(13, ChangeType.Update, Guid.Empty), // 13 -> i=9
93+
new FakeChange(14, ChangeType.Delete, Guid.Empty), // 14 -> i=14
94+
});
95+
96+
Assert.That(string.Join(":", changes.Partitioned.Select(change => change.Generation.ToString("D2"))),
97+
Is.EqualTo("05:07:11:12:00:02:04:09:13:03:06:08:14:01:10"));
98+
}
7399
}
74100

75101
public class FakeChange : IChangeLogRow

DotJEM.Json.Storage/Adapter/Materialize/ChanceLog/IStorageChangeCollection.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public StorageChangeCollection(string storageArea, long generation, List<IChange
100100
cursor[(int)ChangeType.Create] = 0;
101101
cursor[(int)ChangeType.Update] = count[(int)ChangeType.Create];
102102
cursor[(int)ChangeType.Delete] = count[(int)ChangeType.Create] + count[(int)ChangeType.Update];
103-
cursor[(int)ChangeType.Faulty] = count[(int)ChangeType.Create] + count[(int)ChangeType.Update] + count[(int)ChangeType.Faulty];
103+
cursor[(int)ChangeType.Faulty] = count[(int)ChangeType.Create] + count[(int)ChangeType.Update] + count[(int)ChangeType.Delete];
104104
foreach (IChangeLogRow change in changes)
105105
{
106106
int i = cursor[(int) change.Type]++;

0 commit comments

Comments
 (0)