From 72ce72be1c18021669c203cf76ac30b4e872a1ce Mon Sep 17 00:00:00 2001 From: Brian Runck Date: Tue, 13 Aug 2019 22:12:18 -0400 Subject: [PATCH 1/3] Alter unit test to reproduce merge graph problem seen in issue #322 --- src/MobileKidsIdApp.Models.Test/FamilyTests.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/MobileKidsIdApp.Models.Test/FamilyTests.cs b/src/MobileKidsIdApp.Models.Test/FamilyTests.cs index 4d87afa..e19dc86 100644 --- a/src/MobileKidsIdApp.Models.Test/FamilyTests.cs +++ b/src/MobileKidsIdApp.Models.Test/FamilyTests.cs @@ -55,13 +55,18 @@ public async Task AddChild() } [TestMethod] - public async Task MergeSavedFamily() + public async Task MergeSavedFamilyWithOnePhotoAdded() { var family = await Csla.DataPortal.FetchAsync(); - var child = family.AddNew(); - var nextChild = family.AddNew(); - child.Photos.AddNew(); - nextChild.Photos.AddNew(); + for (int i = 0; i < 4; i++) + { + var child = family.AddNew(); + // add photo to the last Child + if (i == 3) + { + child.Photos.AddNew(); + } + } var saved = await family.SaveAsync(); From 6698de28f8c1ed3320f8a84065ab69763d9453a0 Mon Sep 17 00:00:00 2001 From: Brian Runck Date: Wed, 14 Aug 2019 11:54:03 -0400 Subject: [PATCH 2/3] Invert unit test assertion so that it passes on the undesired behavior. That way it won't break the build and can also be used to investigate the problem in issue 332. --- src/MobileKidsIdApp.Models.Test/FamilyTests.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/MobileKidsIdApp.Models.Test/FamilyTests.cs b/src/MobileKidsIdApp.Models.Test/FamilyTests.cs index e19dc86..5559102 100644 --- a/src/MobileKidsIdApp.Models.Test/FamilyTests.cs +++ b/src/MobileKidsIdApp.Models.Test/FamilyTests.cs @@ -55,6 +55,9 @@ public async Task AddChild() } [TestMethod] + [Description("This demonstrates the problem described in issue 332. " + + "Once fixed, this test should be updated to assert for the proper result which is that " + + "the two collections are functionally equal.")] public async Task MergeSavedFamilyWithOnePhotoAdded() { var family = await Csla.DataPortal.FetchAsync(); @@ -71,7 +74,8 @@ public async Task MergeSavedFamilyWithOnePhotoAdded() var saved = await family.SaveAsync(); new Csla.Core.GraphMerger().MergeBusinessListGraph(family, saved); - Assert.AreEqual(saved.Count, family.Count); + // TODO: fix issue 332 and once done, change this to check for equality to exercise that fix. + Assert.AreNotEqual(saved.Count, family.Count); } [TestMethod] From a73e90232a3365104ed6b6be8262689b1185d680 Mon Sep 17 00:00:00 2001 From: Brian Runck Date: Wed, 14 Aug 2019 12:05:53 -0400 Subject: [PATCH 3/3] introduce constant --- src/MobileKidsIdApp.Models.Test/FamilyTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/MobileKidsIdApp.Models.Test/FamilyTests.cs b/src/MobileKidsIdApp.Models.Test/FamilyTests.cs index 5559102..19d8078 100644 --- a/src/MobileKidsIdApp.Models.Test/FamilyTests.cs +++ b/src/MobileKidsIdApp.Models.Test/FamilyTests.cs @@ -60,12 +60,14 @@ public async Task AddChild() "the two collections are functionally equal.")] public async Task MergeSavedFamilyWithOnePhotoAdded() { + const int totalChildren = 4; + var family = await Csla.DataPortal.FetchAsync(); - for (int i = 0; i < 4; i++) + for (int i = 0; i < totalChildren; i++) { var child = family.AddNew(); // add photo to the last Child - if (i == 3) + if (i == totalChildren - 1) { child.Photos.AddNew(); }