Ejemplo n.º 1
0
        public void GetGridsByDisplayName_OnMultipleFound_ShouldReturnAll_AndOnlyTheMatches()
        {
            string TestDisplayName = "TestDisplayName";

            XElement TestBlueprint = TestHelpers.DataBuilder.BuildBlueprint()
                                     .AndGridWith()
                                     .DisplayName(TestDisplayName)
                                     .ExportThis(out var Res1) // Note out Res1
                                     .ThatsAll()
                                     .AndGridWith()
                                     .DisplayName(TestDisplayName)
                                     .ExportThis(out var Res2) // Note out Res2
                                     .ThatsAll()
                                     .AndGridWith()
                                     .DisplayName("DifferentName")
                                     .ThatsAll();

            List <XElement> ExpectedResultList = new List <XElement>()
            {
                Res1, Res2
            };

            BlueprintDataContext DataContext = new BlueprintDataContext(TestBlueprint);

            // Affirm preconditions
            Assert.That(TestBlueprint.Descendants("DisplayName").Where(e => e.Value == TestDisplayName).Count, Is.EqualTo(2),
                        "Test blueprint should contain two instances of the tested DisplayName.");

            var res = DataContext.GetGridsByDisplayName(TestDisplayName);

            Assert.That(res, Is.EquivalentTo(ExpectedResultList),
                        "Tested method should return two grids with matching display names, and nothing else.");
        }
Ejemplo n.º 2
0
        public void GetGridsByDisplayName_OnNoneFound_ShouldReturnEmptyCollection()
        {
            string TestDisplayName = "TestDisplayName";

            XElement TestBlueprint = TestHelpers.DataBuilder.BuildBlueprint()
                                     .AndGridWith()
                                     .DisplayName("arbitraryNameOne")
                                     .ThatsAll()
                                     .AndGridWith()
                                     .DisplayName("arbitraryNameTwo")
                                     .ThatsAll();

            BlueprintDataContext DataContext = new BlueprintDataContext(TestBlueprint);

            // Affirm preconditions
            Assert.That(TestBlueprint.Descendants("DisplayName").Where(e => e.Value == TestDisplayName).Count, Is.Zero,
                        "Test blueprint should not contain the tested DisplayName.");

            var res = DataContext.GetGridsByDisplayName(TestDisplayName);

            Assert.That(res, Is.Not.Null.And.Empty);
        }