Esempio n. 1
0
        public void Roundtrip_DateTime_ranges_through_ToString_and_Parse(NpgsqlRange <DateTime> input)
        {
            var wellKnownText = input.ToString();
            var result        = NpgsqlRange <DateTime> .Parse(wellKnownText);

            Assert.AreEqual(input, result);
        }
Esempio n. 2
0
        public void GivenIntRangeLiteral_WhenParsed_ThenReturnsIntRange(string input)
        {
            // Act
            var result = NpgsqlRange <int> .Parse(input);

            // Assert
            Assert.AreEqual(input.Replace(" ", null), result.ToString());
        }
Esempio n. 3
0
        public void GivenPoorlyFormedNullableIntRangeLiteral_WhenParsed_ThenReturnsNullableIntRange(string input, string normalized)
        {
            // Act
            var result = NpgsqlRange <int?> .Parse(input);

            // Assert
            Assert.AreEqual(normalized, result.ToString());
        }
Esempio n. 4
0
        public void GivenStringRangeLiteral_WhenParsed_ThenReturnsStringRange(string input, string normalized)
        {
            // Act
            var result = NpgsqlRange <string> .Parse(input);

            // Assert
            Assert.AreEqual(normalized, result.ToString());
        }
Esempio n. 5
0
        public void GivenSimpleTypeRangeLiteral_WhenParsed_ThenReturnsSimpleTypeRange(string input)
        {
            // Act
            var result = NpgsqlRange <SimpleType> .Parse(input);

            // Assert
            Assert.AreEqual(input, result.ToString());
        }
Esempio n. 6
0
        public void GivenEmptyIntRangeLiteral_WhenParsed_ThenReturnsEmptyIntRange(string value)
        {
            // Act
            var result = NpgsqlRange <int> .Parse(value);

            // Assert
            Assert.AreEqual(NpgsqlRange <int> .Empty, result);
        }
Esempio n. 7
0
        public void UserDefinedSchemaQualified()
        {
            using var context = CreateContext();
            var e = context.RangeTestEntities.Single(x => x.SchemaRange == NpgsqlRange <double> .Parse("(0,10)"));

            AssertContainsSql(@"WHERE r.""SchemaRange"" = '(0,10)'::test.""Schema_Range""");
            Assert.Equal(0, e.SchemaRange.LowerBound);
            Assert.Equal(10, e.SchemaRange.UpperBound);
        }
Esempio n. 8
0
 public void UserDefinedSchemaQualified()
 {
     using (var context = Fixture.CreateContext())
     {
         var e = context.RangeTestEntities.Single(x => x.SchemaRange == NpgsqlRange <double> .Parse("(0,10)"));
         AssertContainsSql("WHERE x.\"SchemaRange\" = @__Parse_0");
         Assert.Equal(e.SchemaRange.LowerBound, 0);
         Assert.Equal(e.SchemaRange.UpperBound, 10);
     }
 }
Esempio n. 9
0
        public void GivenDateRangeLiteral_WhenConverted_ThenReturnsDateRange(NpgsqlRange <DateTime> input)
        {
            // Arrange
            var wellKnownText = input.ToString();

            // Act
            var result = NpgsqlRange <DateTime> .Parse(wellKnownText);

            // Assert
            Assert.AreEqual(input, result);
        }
Esempio n. 10
0
        public void RangeHashCode_ValueTypes()
        {
            NpgsqlRange <int> a = default;
            NpgsqlRange <int> b = NpgsqlRange <int> .Empty;
            NpgsqlRange <int> c = NpgsqlRange <int> .Parse("(,)");

            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(a.Equals(c));
            Assert.IsFalse(b.Equals(c));
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
            Assert.AreNotEqual(a.GetHashCode(), c.GetHashCode());
            Assert.AreNotEqual(b.GetHashCode(), c.GetHashCode());
        }
Esempio n. 11
0
        public void RangeHashCode_ReferenceTypes()
        {
            NpgsqlRange <string> a = default;
            NpgsqlRange <string> b = NpgsqlRange <string> .Empty;
            NpgsqlRange <string> c = NpgsqlRange <string> .Parse("(,)");

            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(a.Equals(c));
            Assert.IsFalse(b.Equals(c));
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
            Assert.AreNotEqual(a.GetHashCode(), c.GetHashCode());
            Assert.AreNotEqual(b.GetHashCode(), c.GetHashCode());
        }
Esempio n. 12
0
        private void btnUredi_Click(object sender, EventArgs e)
        {
            uredjivanjeUgovora = true;
            SakrijGlavneButtone();
            if (dgvUgovori.SelectedCells.Count > 0)
            {
                int indeksOznacenog = dgvUgovori.SelectedCells[0].RowIndex;

                DataGridViewRow oznaceniRed = dgvUgovori.Rows[indeksOznacenog];

                ID_ugovora = int.Parse(oznaceniRed.Cells["IDUgovora"].Value.ToString());
                cmbPoslodavac.SelectedValue = int.Parse(oznaceniRed.Cells["IDPoslodavca"].Value.ToString());
                cmbPosao.SelectedValue      = int.Parse(oznaceniRed.Cells["IDPosla"].Value.ToString());
                cmbStudent.SelectedValue    = int.Parse(oznaceniRed.Cells["IDStudenta"].Value.ToString());
                NpgsqlRange <DateTime> trajanje = NpgsqlRange <DateTime> .Parse(oznaceniRed.Cells["Trajanje"].Value.ToString());

                dtpOd.Value = trajanje.LowerBound;
                dtpDo.Value = trajanje.UpperBound;
            }
        }
Esempio n. 13
0
        private void dgvUgovori_SelectionChanged(object sender, EventArgs e)
        {
            if (dgvUgovori.SelectedCells.Count > 0)
            {
                int indeksOznacenog = dgvUgovori.SelectedCells[0].RowIndex;

                DataGridViewRow oznaceniRed = dgvUgovori.Rows[indeksOznacenog];
                ID_ugovora = int.Parse(oznaceniRed.Cells["IDUgovora"].Value.ToString());
                satnica    = double.Parse(oznaceniRed.Cells["SatnicaUgovor"].Value.ToString());
                cmbPoslodavac.SelectedValue = int.Parse(oznaceniRed.Cells["IDPoslodavca"].Value.ToString());
                cmbPosao.SelectedValue      = int.Parse(oznaceniRed.Cells["IDPosla"].Value.ToString());
                cmbStudent.SelectedValue    = int.Parse(oznaceniRed.Cells["IDStudenta"].Value.ToString());
                NpgsqlRange <DateTime> trajanje = NpgsqlRange <DateTime> .Parse(oznaceniRed.Cells["Trajanje"].Value.ToString());

                dtpOd.Value = trajanje.LowerBound;
                dtpDo.Value = trajanje.UpperBound;

                txtZaIsplatiti.Text = Upiti.DohvatiIznosZaIsplatiti(ID_ugovora);
                OsvjeziStavke(ID_ugovora);
            }
        }
Esempio n. 14
0
 public void GivenMalformedRangeLiteral_WhenParsed_ThenThrowsFormatException(string input)
 {
     Assert.Throws <FormatException>(() => NpgsqlRange <int> .Parse(input));
 }
Esempio n. 15
0
        public void Parse_empty(string value)
        {
            var result = NpgsqlRange <int> .Parse(value);

            Assert.AreEqual(NpgsqlRange <int> .Empty, result);
        }
Esempio n. 16
0
        public void Roundtrip_int_ranges_through_ToString_and_Parse(string input)
        {
            var result = NpgsqlRange <int> .Parse(input);

            Assert.AreEqual(input.Replace(" ", null), result.ToString());
        }
Esempio n. 17
0
        public void String_range_Parse_ToString_returns_normalized_representations(string input, string normalized)
        {
            var result = NpgsqlRange <string> .Parse(input);

            Assert.AreEqual(normalized, result.ToString());
        }
Esempio n. 18
0
        public void Roundtrip_string_ranges_through_ToString_and_Parse2(string input)
        {
            var result = NpgsqlRange <SimpleType> .Parse(input);

            Assert.AreEqual(input, result.ToString());
        }
Esempio n. 19
0
 public void Parse_malformed_range_throws(string input)
 => Assert.Throws <FormatException>(() => NpgsqlRange <int> .Parse(input));