Skip to content

Commit 05b3a71

Browse files
Ignore CLDS.TestCopyPaste for 2 sprints.
1 parent 2e600ef commit 05b3a71

File tree

1 file changed

+71
-74
lines changed

1 file changed

+71
-74
lines changed

com.unity.sg2/Tests/ContextLayeredDataStorage/ContextLayeredDataStorageTests.cs

+71-74
Original file line numberDiff line numberDiff line change
@@ -517,80 +517,77 @@ public void IsSubPathWorks()
517517
}
518518
}
519519
}
520+
521+
[Ignore("GSG-1614", Until="2023-03-15")]
522+
[Test]
523+
public void TestCopyPaste()
524+
{
525+
ContextLayeredDataStorage clds = new ContextLayeredDataStorage();
526+
clds.AddData("a");
527+
clds.AddData("a.b", 13);
528+
clds.AddData("a.b.c", 35.4f);
529+
clds.AddData("a.b.c.d.e", true);
530+
clds.SetMetadata("a.b", "foo", new Color(1, 0, 0));
520531

521-
// TODO (Brett) This is commented out to bring tests to a passing status.
522-
// TODO (Brett) This test was not removed because it is indicating a valuable failure
523-
// TODO (Brett) that should be addressed.
524-
525-
// [Test]
526-
// public void TestCopyPaste()
527-
// {
528-
// ContextLayeredDataStorage clds = new ContextLayeredDataStorage();
529-
// clds.AddData("a");
530-
// clds.AddData("a.b", 13);
531-
// clds.AddData("a.b.c", 35.4f);
532-
// clds.AddData("a.b.c.d.e", true);
533-
// clds.SetMetadata("a.b", "foo", new Color(1, 0, 0));
534-
//
535-
// List<DataReader> elements = new List<DataReader>()
536-
// {
537-
// clds.Search("a"),
538-
// clds.Search("a.b"),
539-
// clds.Search("a.b.c"),
540-
// clds.Search("a.b.c.d.e")
541-
// };
542-
//
543-
// var ser = clds.CopyElementCollection(elements);
544-
//
545-
// //Paste into same CLDS
546-
// clds.PasteElementCollection(ser.layer, ser.metadata, "Root", out _);
547-
// var copied = clds.Search("a_1");
548-
// Assert.NotNull(copied);
549-
// Assert.IsTrue(copied.GetChildren().Count() == 1);
550-
// copied = copied.GetChild("b");
551-
// Assert.NotNull(copied);
552-
// Assert.AreEqual(13, copied.GetData<int>());
553-
// Assert.AreEqual(new Color(1, 0, 0), clds.GetMetadata<Color>(copied.Element.ID, "foo"));
554-
// Assert.IsTrue(copied.GetChildren().Count() == 1);
555-
// copied = copied.GetChild("c");
556-
// Assert.NotNull(copied);
557-
// Assert.AreEqual(35.4f, copied.GetData<float>());
558-
// //Okay, so this is a weird one and I want to explain it, since either myself in 3 months or
559-
// //whoever is looking at this code later might think this is a bug. Of course "c" has a child,
560-
// //its "d.e"! But what needs to be remembered is we act on the flat structure, and "GetChildren"
561-
// //will only return the _immediate_ children of a reader (at least in the base DataReader case).
562-
// //That means, if "d" were contained in this structure, it could be returned. But since its not
563-
// //here, and "d.e" wont be seen as an immediate child, its ignored.
564-
// Assert.AreEqual(0, copied.GetChildren().Count());
565-
// //This part though seems to go against that; "c" has no children, why can you getchild on "d.e"
566-
// //and get a correct value? Currently, getchild just appends the rest of the localID onto c's
567-
// //full path ID, and then just searches the graph for that, which will search for "a.b.c.d.e"
568-
// //and find the correct value. The name could potentially be changed, but thats really up to
569-
// //how the reader is implemented.
570-
// copied = copied.GetChild("d.e");
571-
// Assert.NotNull(copied);
572-
// Assert.AreEqual(true, copied.GetData<bool>());
573-
// Assert.IsTrue(copied.GetChildren().Count() == 0);
574-
//
575-
// //Paste into new CLDS
576-
// clds = new ContextLayeredDataStorage();
577-
// clds.PasteElementCollection(ser.layer, ser.metadata, "Root", out _);
578-
// copied = clds.Search("a");
579-
// Assert.NotNull(copied);
580-
// Assert.IsTrue(copied.GetChildren().Count() == 1);
581-
// copied = copied.GetChild("b");
582-
// Assert.NotNull(copied);
583-
// Assert.AreEqual(13, copied.GetData<int>());
584-
// Assert.AreEqual(new Color(1, 0, 0), clds.GetMetadata<Color>(copied.Element.ID, "foo"));
585-
// Assert.IsTrue(copied.GetChildren().Count() == 1);
586-
// copied = copied.GetChild("c");
587-
// Assert.NotNull(copied);
588-
// Assert.AreEqual(35.4f, copied.GetData<float>());
589-
// Assert.AreEqual(0, copied.GetChildren().Count());
590-
// copied = copied.GetChild("d.e");
591-
// Assert.NotNull(copied);
592-
// Assert.AreEqual(true, copied.GetData<bool>());
593-
// Assert.IsTrue(copied.GetChildren().Count() == 0);
594-
// }
532+
List<DataReader> elements = new List<DataReader>()
533+
{
534+
clds.Search("a"),
535+
clds.Search("a.b"),
536+
clds.Search("a.b.c"),
537+
clds.Search("a.b.c.d.e")
538+
};
539+
540+
var ser = clds.CopyElementCollection(elements);
541+
542+
//Paste into same CLDS
543+
clds.PasteElementCollection(ser.layer, ser.metadata, "Root", out _);
544+
var copied = clds.Search("a_1");
545+
Assert.NotNull(copied);
546+
Assert.IsTrue(copied.GetChildren().Count() == 1);
547+
copied = copied.GetChild("b");
548+
Assert.NotNull(copied);
549+
Assert.AreEqual(13, copied.GetData<int>());
550+
Assert.AreEqual(new Color(1, 0, 0), clds.GetMetadata<Color>(copied.Element.ID, "foo"));
551+
Assert.IsTrue(copied.GetChildren().Count() == 1);
552+
copied = copied.GetChild("c");
553+
Assert.NotNull(copied);
554+
Assert.AreEqual(35.4f, copied.GetData<float>());
555+
//Okay, so this is a weird one and I want to explain it, since either myself in 3 months or
556+
//whoever is looking at this code later might think this is a bug. Of course "c" has a child,
557+
//its "d.e"! But what needs to be remembered is we act on the flat structure, and "GetChildren"
558+
//will only return the _immediate_ children of a reader (at least in the base DataReader case).
559+
//That means, if "d" were contained in this structure, it could be returned. But since its not
560+
//here, and "d.e" wont be seen as an immediate child, its ignored.
561+
Assert.AreEqual(0, copied.GetChildren().Count());
562+
//This part though seems to go against that; "c" has no children, why can you getchild on "d.e"
563+
//and get a correct value? Currently, getchild just appends the rest of the localID onto c's
564+
//full path ID, and then just searches the graph for that, which will search for "a.b.c.d.e"
565+
//and find the correct value. The name could potentially be changed, but thats really up to
566+
//how the reader is implemented.
567+
copied = copied.GetChild("d.e");
568+
Assert.NotNull(copied);
569+
Assert.AreEqual(true, copied.GetData<bool>());
570+
Assert.IsTrue(copied.GetChildren().Count() == 0);
571+
572+
//Paste into new CLDS
573+
clds = new ContextLayeredDataStorage();
574+
clds.PasteElementCollection(ser.layer, ser.metadata, "Root", out _);
575+
copied = clds.Search("a");
576+
Assert.NotNull(copied);
577+
Assert.IsTrue(copied.GetChildren().Count() == 1);
578+
copied = copied.GetChild("b");
579+
Assert.NotNull(copied);
580+
Assert.AreEqual(13, copied.GetData<int>());
581+
Assert.AreEqual(new Color(1, 0, 0), clds.GetMetadata<Color>(copied.Element.ID, "foo"));
582+
Assert.IsTrue(copied.GetChildren().Count() == 1);
583+
copied = copied.GetChild("c");
584+
Assert.NotNull(copied);
585+
Assert.AreEqual(35.4f, copied.GetData<float>());
586+
Assert.AreEqual(0, copied.GetChildren().Count());
587+
copied = copied.GetChild("d.e");
588+
Assert.NotNull(copied);
589+
Assert.AreEqual(true, copied.GetData<bool>());
590+
Assert.IsTrue(copied.GetChildren().Count() == 0);
591+
}
595592
}
596593
}

0 commit comments

Comments
 (0)