Exemplo n.º 1
0
        public void GetDataPins_NotEmpty_Ok()
        {
            MsHistoryPart part = GetEmptyPart();

            for (int n = 1; n <= 3; n++)
            {
                bool even = n % 2 == 0;
                part.Provenances.Add(new GeoAddress
                {
                    Area = even ? "France" : "Italy",
                });
                part.Owners.Add(even ? "even" : "odd");
            }

            List <DataPin> pins = part.GetDataPins(null).ToList();

            Assert.Equal(4, pins.Count);

            DataPin pin = pins.Find(p => p.Name == "area" && p.Value == "italy");

            Assert.NotNull(pin);
            TestHelper.AssertPinIds(part, pin);

            pin = pins.Find(p => p.Name == "area" && p.Value == "france");
            Assert.NotNull(pin);
            TestHelper.AssertPinIds(part, pin);

            pin = pins.Find(p => p.Name == "owner" && p.Value == "even");
            Assert.NotNull(pin);
            TestHelper.AssertPinIds(part, pin);

            pin = pins.Find(p => p.Name == "owner" && p.Value == "odd");
            Assert.NotNull(pin);
            TestHelper.AssertPinIds(part, pin);
        }
Exemplo n.º 2
0
        public void GetDataPins_Empty_NoPin()
        {
            MsHistoryPart part = GetEmptyPart();

            Assert.Empty(part.GetDataPins(null));
        }
Exemplo n.º 3
0
        public void GetDataPins_Ok()
        {
            MsHistoryPart part = GetPart(3);

            List <DataPin> pins = part.GetDataPins(null).ToList();

            Assert.Equal(17, pins.Count);
            TestHelper.AssertValidDataPinNames(pins);

            DataPin pin = pins.Find(p => p.Name == "area");

            Assert.NotNull(pin);
            TestHelper.AssertPinIds(part, pin);
            Assert.Equal("provence", pin.Value);

            pin = pins.Find(p => p.Name == "pers-count");
            Assert.NotNull(pin);
            TestHelper.AssertPinIds(part, pin);
            Assert.Equal("3", pin.Value);

            pin = pins.Find(p => p.Name == "ann-count");
            Assert.NotNull(pin);
            TestHelper.AssertPinIds(part, pin);
            Assert.Equal("3", pin.Value);

            pin = pins.Find(p => p.Name == "rest-count");
            Assert.NotNull(pin);
            TestHelper.AssertPinIds(part, pin);
            Assert.Equal("3", pin.Value);

            for (int n = 1; n <= 3; n++)
            {
                pins.Find(p => p.Name == "pers-name" &&
                          p.Value == $"robert mc{n}");
                Assert.NotNull(pin);
                TestHelper.AssertPinIds(part, pin);

                var date = HistoricalDate.Parse(
                    (1200 + n).ToString(CultureInfo.InvariantCulture) + " AD");
                string expectedDate =
                    date.GetSortValue().ToString(CultureInfo.InvariantCulture);

                pin = pins.Find(p => p.Name == "pers-date-value" &&
                                p.Value == expectedDate);
                Assert.NotNull(pin);
                TestHelper.AssertPinIds(part, pin);

                pin = pins.Find(p => p.Name == "rest-date-value" &&
                                p.Value == expectedDate);
                Assert.NotNull(pin);
                TestHelper.AssertPinIds(part, pin);
            }

            pin = pins.Find(p => p.Name == "ann-odd-count");
            Assert.NotNull(pin);
            TestHelper.AssertPinIds(part, pin);
            Assert.Equal("2", pin.Value);

            pin = pins.Find(p => p.Name == "ann-even-count");
            Assert.NotNull(pin);
            TestHelper.AssertPinIds(part, pin);
            Assert.Equal("1", pin.Value);

            pin = pins.Find(p => p.Name == "rest-odd-count");
            Assert.NotNull(pin);
            TestHelper.AssertPinIds(part, pin);
            Assert.Equal("2", pin.Value);

            pin = pins.Find(p => p.Name == "rest-even-count");
            Assert.NotNull(pin);
            TestHelper.AssertPinIds(part, pin);
            Assert.Equal("1", pin.Value);
        }