Skip to content

Commit bbab1a4

Browse files
committed
Add publication changes to RegressionDeserializationData.json
1 parent 7f41e89 commit bbab1a4

4 files changed

Lines changed: 51 additions & 5 deletions

File tree

backend/FwLite/LcmCrdt.Tests/Changes/RegressionDeserializationData.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,38 @@
238238
"ComplexFormTypeId": "d4b5503e-9381-a73d-6b18-eb3dae571f25",
239239
"EntityId": "428b9279-8cbb-bcda-49e2-1ff80d8cba2f"
240240
},
241+
{
242+
"$type": "AddPublicationChange",
243+
"Publication": {
244+
"Id": "84597629-7d00-a415-9ac1-2865b7efa9bf",
245+
"DeletedAt": null,
246+
"Name": {
247+
"dgw": "Money Market Account",
248+
"yrn": "parse"
249+
}
250+
},
251+
"EntityId": "4dcbedc5-c4f1-54fd-f0b0-ede17a5af7e7"
252+
},
253+
{
254+
"$type": "RemovePublicationChange",
255+
"PublicationId": "26a3eeec-bd3d-fa76-c66d-7d41df729d1f",
256+
"EntityId": "3f1e7bbf-ea5f-fdfd-6f24-2cf129fce912"
257+
},
258+
{
259+
"$type": "ReplacePublicationChange",
260+
"NewPublication": {
261+
"Id": "09c00842-481a-516f-f9fc-e6732c9ada73",
262+
"DeletedAt": null,
263+
"Name": {
264+
"iap": "whiteboard",
265+
"jiy": "Trafficway",
266+
"enu": "Kip",
267+
"dtm": "optimize"
268+
}
269+
},
270+
"OldPublicationId": "e0fca592-c089-8850-8026-0c34610352fa",
271+
"EntityId": "727546c3-8a97-c721-4a9a-5205cc029c77"
272+
},
241273
{
242274
"$type": "CreateComplexFormType",
243275
"Name": {

backend/FwLite/LcmCrdt.Tests/Changes/UseChangesTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,19 @@ private static IEnumerable<ChangeWithDependencies> GetAllChanges()
167167

168168
var createPublicationChange = new CreatePublicationChange(Guid.NewGuid(), new (){{"en", "Main"}});
169169
yield return new ChangeWithDependencies(createPublicationChange);
170+
171+
var publication = new Publication { Id = Guid.NewGuid(), Name = { { "en", "Main" } } };
172+
var addPublicationChange = new AddPublicationChange(Guid.NewGuid(), publication);
173+
yield return new ChangeWithDependencies(addPublicationChange);
174+
175+
var publication2 = new Publication { Id = Guid.NewGuid(), Name = { { "en", "Second" } } };
176+
var addPublication2Change = new AddPublicationChange(Guid.NewGuid(), publication2);
177+
yield return new ChangeWithDependencies(addPublication2Change);
178+
179+
var replacePublicationChange = new ReplacePublicationChange(Guid.NewGuid(), publication2, publication.Id);
180+
yield return new ChangeWithDependencies(replacePublicationChange, [addPublicationChange, addPublication2Change]);
181+
182+
var removePublicationChange = new RemovePublicationChange(Guid.NewGuid(), publication2.Id);
183+
yield return new ChangeWithDependencies(removePublicationChange, [replacePublicationChange]);
170184
}
171185
}

backend/FwLite/LcmCrdt/Changes/Entries/AddPublicationChange.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ namespace LcmCrdt.Changes.Entries;
77
public class AddPublicationChange(Guid entityId, Publication publication)
88
: EditChange<Entry>(entityId), ISelfNamedType<AddPublicationChange>
99
{
10-
public Publication publication { get; } = publication;
10+
public Publication Publication { get; } = publication;
1111

1212
public override async ValueTask ApplyChange(Entry entity, IChangeContext context)
1313
{
14-
if (await context.IsObjectDeleted(publication.Id)) return;
15-
entity.PublishIn.Add(publication);
14+
if (await context.IsObjectDeleted(Publication.Id)) return;
15+
entity.PublishIn.Add(Publication);
1616
}
1717
}

backend/FwLite/LcmCrdt/Changes/Entries/RemovePublicationChange.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ namespace LcmCrdt.Changes.Entries;
66

77
public class RemovePublicationChange(Guid entityId, Guid publicationId) : EditChange<Entry>(entityId), ISelfNamedType<RemovePublicationChange>
88
{
9-
public Guid publicationId { get; } = publicationId;
9+
public Guid PublicationId { get; } = publicationId;
1010
public override ValueTask ApplyChange(Entry entity, IChangeContext context)
1111
{
12-
entity.PublishIn = entity.PublishIn.Where(t => t.Id != publicationId).ToList();
12+
entity.PublishIn = entity.PublishIn.Where(t => t.Id != PublicationId).ToList();
1313
return ValueTask.CompletedTask;
1414
}
1515
}

0 commit comments

Comments
 (0)