public void GetBlocksBySubtypeName_OnOneGridNotFound_ShouldReturnEmptyCollection() { string TestSubtypeName = "TestSubtypeName"; // Test data that doesn't contain any matching element on target grid, but contains on another grid XElement TestBlueprint = TestHelpers.DataBuilder.BuildBlueprint() .AndGridWith() .AndBlockWith().ThatsAll() .AndBlockWith().ThatsAll() .ExportThis(out var TargetGrid) // Note out TargetGrid .ThatsAll() .AndGridWith() .AndBlockWith().SubtypeName(TestSubtypeName).ThatsAll() // Note SubtypeName set .AndBlockWith().ThatsAll(); BlueprintDataContext DataContext = new BlueprintDataContext(TestBlueprint); // Affirm preconditions Assert.Multiple(() => { Assert.That(TargetGrid.Descendants("SubtypeName").Where(e => e.Value == TestSubtypeName).Count, Is.Zero, $"Test blueprints's target grid shouldn't contain any nodes with SubtypeName of {TestSubtypeName}."); Assert.That(TestBlueprint.Descendants("SubtypeName").Where(e => e.Value == TestSubtypeName).Count, Is.Not.Zero, $"Test blueprint should contain at least one node with SubtypeName of {TestSubtypeName} on a non-target grid."); }); var res = DataContext.GetBlocksBySubtypeName(TestSubtypeName, TargetGrid); Assert.That(res, Is.Not.Null.And.Empty); }
public void GetBlocksWithProperty_OnOneGridNoneFound_ShouldReturnEmptyCollection() { string TestPropertyName = "IntegrityPercent"; // Test data that doesn't contain any matching element on target grid, but contains on another grid XElement TestBlueprint = TestHelpers.DataBuilder.BuildBlueprint() .AndGridWith() .AndBlockWith().ThatsAll() .AndBlockWith().ThatsAll() .ExportThis(out var TargetGrid) // Note out TargetGrid .ThatsAll() .AndGridWith() .AndBlockWith().Integrity(0.5).ThatsAll() // Note Integrity set .AndBlockWith().ThatsAll(); BlueprintDataContext DataContext = new BlueprintDataContext(TestBlueprint); // Affirm preconditions Assert.Multiple(() => { Assert.That(TargetGrid.Descendants("IntegrityPercent").Count, Is.Zero, $"Test blueprints's target grid shouldn't contain any {TestPropertyName} nodes."); Assert.That(TestBlueprint.Descendants("IntegrityPercent").Count, Is.Not.Zero, $"Test blueprint should contain at least one {TestPropertyName} node on a non-target grid."); }); var res = DataContext.GetBlocksWithProperty(TestPropertyName, TargetGrid); Assert.That(res, Is.Not.Null.And.Empty); }