示例#1
0
        public void test_czy_atrybut_ma_nazwę_i_wartość()
        {
            var atrybut = new AtrybutOpisowy(nazwa: "ID", wartość: "1");

            Assert.AreEqual(expected: "ID", actual: atrybut.Nazwa);
            Assert.AreEqual(expected: "1", actual: atrybut.Wartość);
        }
示例#2
0
        public static AtrybutOpisowy ParseAtrybut(this string record)
        {
            //:ID[C353953E-1BCE-4D6A-B5D4-AB17D6C32D1D]
            if (string.IsNullOrEmpty(record))
            {
                throw new ArgumentNullException("Rekord atrybutu opisowego jest pusty");
            }
            if (!record.StartsWith(":"))
            {
                throw new ArgumentException("Rekord atrybutu opisowego nie zaczyna się od dwukropka :");
            }
            if (!record.EndsWith("]"))
            {
                throw new ArgumentException("Rekord atrybutu opisowego nie kończy się prawym nawiasem ]");
            }
            var recordWithoutColon = record
                                     .Substring(1)
                                     .TrimEnd(']');
            var leftIndex = recordWithoutColon
                            .IndexOf('[');

            if (leftIndex < 0)
            {
                throw new ArgumentException("Rekord atrybutu opisowego nie zawiera lewego nawiasu [");
            }
            var name = recordWithoutColon
                       .Substring(0, leftIndex);
            var valueIndex = leftIndex + 1;
            var value      = recordWithoutColon.Substring(valueIndex);
            var atrybut    = new AtrybutOpisowy(name, value);

            return(atrybut);
        }
示例#3
0
        public void test_czy_atrybut_nie_jest_listą()
        {
            var atrybut = new AtrybutOpisowy(nazwa: "ID", wartość: "1");

            Assert.AreEqual(expected: "ID", actual: atrybut.Nazwa);
            Assert.AreEqual(expected: "1", actual: atrybut.Wartość);
            Assert.IsFalse(atrybut.JestListą);
            Assert.AreEqual(expected: 0, actual: atrybut.Count());
            Assert.AreEqual(expected: 0, actual: atrybut.Wartości.Count());
        }
示例#4
0
        public void test_czy_atrybut_będący_listą_wielu_wartości_ma_wartość()
        {
            var atrybut = new AtrybutOpisowy(
                nazwa: "KR",
                wartość: "#LIST;GG-III.6640.1974.2015=42496.43125,PSobczak;3006-26/2008=42496.42961,PSobczak");

            Assert.AreEqual(expected: "KR", actual: atrybut.Nazwa);
            Assert.IsTrue(atrybut.JestListą);
            var wartość = atrybut.Wartość;

            Assert.Fail();
        }
示例#5
0
        public void test_czy_atrybut_jest_listą_z_jedną_wartością()
        {
            //:KR[#LIST;GG-III.6640.1974.2015=42496.48844,PSobczak]
            var atrybut = new AtrybutOpisowy(nazwa: "KR", wartość: "#LIST;GG-III.6640.1974.2015=42496.48844,PSobczak");

            Assert.AreEqual(expected: "KR", actual: atrybut.Nazwa);
            //Assert.AreEqual(expected: "GG-III.6640.1974.2015=42496.48844,PSobczak", actual: atrybut.Wartość);
            Assert.IsTrue(atrybut.JestListą);
            Assert.AreEqual(expected: 1, actual: atrybut.Count());
            Assert.AreEqual(expected: 1, actual: atrybut.Wartości.Count());
            Assert.AreEqual(expected: "GG-III.6640.1974.2015=42496.48844,PSobczak", actual: atrybut.First());
        }
示例#6
0
        public void test_czy_atrybut_jest_pustą_listą_bez_wartości()
        {
            //:KR[#LIST;]
            var atrybut = new AtrybutOpisowy(nazwa: "KR", wartość: "#LIST;");

            Assert.AreEqual(expected: "KR", actual: atrybut.Nazwa);
            Assert.IsTrue(atrybut.JestListą);
            Assert.AreEqual(0, atrybut.Count());
            var wartość = atrybut.Wartość;

            Assert.Fail();
        }
示例#7
0
        public void test_czy_mapa_zawiera_dodany_taki_sam_id()
        {
            var map     = new MapaGeoMap();
            var header  = new Nagłówek(1234);
            var element = new ElementMapy(header);
            var guid    = Guid.NewGuid().ToString();
            var id      = new AtrybutOpisowy("ID", guid);

            element.DodajAtrybut(id);
            map.AddElement(element);
            map.AddElement(element);
            Assert.AreEqual(expected: 2, actual: map.Count());
        }
        public void test_czy_element_nie_zawiera_operatów()
        {
            var atrybut = new AtrybutOpisowy(
                nazwa: "KR",
                wartość: "#LIST;");
            var header  = new Nagłówek(code: 1234);
            var element = new ElementMapy(header);

            element.DodajAtrybut(atrybut);
            var operaty = element.Operaty;

            Assert.AreEqual(expected: 0, actual: operaty.Count());
        }
示例#9
0
        public void test_czy_mapa_wyszuka_taki_sam_id()
        {
            var map     = new MapaGeoMap();
            var header  = new Nagłówek(1234);
            var element = new ElementMapy(header);
            var guid    = Guid.NewGuid().ToString();
            var id      = new AtrybutOpisowy("ID", guid);

            element.DodajAtrybut(id);
            map.AddElement(element);
            map.AddElement(element);
            map.Szukaj(guid);
            Assert.Fail();
        }
        public void test_czy_element_zawiera_jeden_operat_bez_operatora()
        {
            var atrybut = new AtrybutOpisowy(
                nazwa: "KR",
                wartość: "123/2016");
            var header  = new Nagłówek(code: 1234);
            var element = new ElementMapy(header);

            element.DodajAtrybut(atrybut);
            var operaty = element.Operaty;

            Assert.AreEqual(expected: 1, actual: operaty.Count());
            var operat = operaty.Single();

            Assert.AreEqual(expected: "123/2016", actual: operat.Numer);
        }
示例#11
0
        public void test_czy_atrybut_jest_listą_wielu_wartości()
        {
            var atrybut = new AtrybutOpisowy(
                nazwa: "KR",
                wartość: "#LIST;GG-III.6640.1974.2015=42496.43125,PSobczak;3006-26/2008=42496.42961,PSobczak");

            Assert.AreEqual(expected: "KR", actual: atrybut.Nazwa);
            //Assert.AreEqual(expected: "#LIST;GG-III.6640.1974.2015=42496.43125,PSobczak;3006-26/2008=42496.42961,PSobczak", actual: atrybut.Wartość);
            Assert.AreEqual(expected: 2, actual: atrybut.Count());
            Assert.IsTrue(atrybut.JestListą);
            var wartość1 = atrybut.First();

            Assert.AreEqual(expected: "GG-III.6640.1974.2015=42496.43125,PSobczak", actual: wartość1);
            var wartość2 = atrybut.Last();

            Assert.AreEqual(expected: "3006-26/2008=42496.42961,PSobczak", actual: wartość2);
        }