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); }
public void GivenIntRangeLiteral_WhenParsed_ThenReturnsIntRange(string input) { // Act var result = NpgsqlRange <int> .Parse(input); // Assert Assert.AreEqual(input.Replace(" ", null), result.ToString()); }
public void GivenPoorlyFormedNullableIntRangeLiteral_WhenParsed_ThenReturnsNullableIntRange(string input, string normalized) { // Act var result = NpgsqlRange <int?> .Parse(input); // Assert Assert.AreEqual(normalized, result.ToString()); }
public void GivenStringRangeLiteral_WhenParsed_ThenReturnsStringRange(string input, string normalized) { // Act var result = NpgsqlRange <string> .Parse(input); // Assert Assert.AreEqual(normalized, result.ToString()); }
public void GivenSimpleTypeRangeLiteral_WhenParsed_ThenReturnsSimpleTypeRange(string input) { // Act var result = NpgsqlRange <SimpleType> .Parse(input); // Assert Assert.AreEqual(input, result.ToString()); }
public void GivenEmptyIntRangeLiteral_WhenParsed_ThenReturnsEmptyIntRange(string value) { // Act var result = NpgsqlRange <int> .Parse(value); // Assert Assert.AreEqual(NpgsqlRange <int> .Empty, result); }
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); }
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); } }
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); }
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()); }
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()); }
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; } }
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); } }
public void GivenMalformedRangeLiteral_WhenParsed_ThenThrowsFormatException(string input) { Assert.Throws <FormatException>(() => NpgsqlRange <int> .Parse(input)); }
public void Parse_empty(string value) { var result = NpgsqlRange <int> .Parse(value); Assert.AreEqual(NpgsqlRange <int> .Empty, result); }
public void Roundtrip_int_ranges_through_ToString_and_Parse(string input) { var result = NpgsqlRange <int> .Parse(input); Assert.AreEqual(input.Replace(" ", null), result.ToString()); }
public void String_range_Parse_ToString_returns_normalized_representations(string input, string normalized) { var result = NpgsqlRange <string> .Parse(input); Assert.AreEqual(normalized, result.ToString()); }
public void Roundtrip_string_ranges_through_ToString_and_Parse2(string input) { var result = NpgsqlRange <SimpleType> .Parse(input); Assert.AreEqual(input, result.ToString()); }
public void Parse_malformed_range_throws(string input) => Assert.Throws <FormatException>(() => NpgsqlRange <int> .Parse(input));