Ejemplo n.º 1
0
        public void TryGetPartTest()
        {
            // Part identifier: "false"
            //      indexes: 0, 10
            //
            // Part identifier: "true"
            //      indexes: 5, 15
            //
            var falsePart = IndexCollection.FromArray(new int[2] {
                0, 10
            });
            var truePart = IndexCollection.FromArray(new int[2] {
                5, 15
            });

            var target = new IndexPartition <string>
            {
                partIndetifiers = new List <string>(2)
                {
                    "false",
                    "true"
                },

                parts = new Dictionary <string, IndexCollection>(2)
                {
                    { "false", falsePart },
                    { "true", truePart }
                }
            };

            bool partFound;

            partFound = target.TryGetPart("unknown", out IndexCollection part);
            Assert.AreEqual(expected: false, actual: partFound);
            Assert.IsNull(part);

            partFound = target.TryGetPart("false", out part);
            Assert.AreEqual(expected: true, actual: partFound);
            IndexCollectionAssert.AreEqual(expected: falsePart, actual: part);

            partFound = target.TryGetPart("true", out part);
            Assert.AreEqual(expected: true, actual: partFound);
            IndexCollectionAssert.AreEqual(expected: truePart, actual: part);
        }