Skip to content

Commit

Permalink
chore: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar committed Sep 25, 2023
1 parent 148b794 commit 181caee
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions Client.Test/Write/PointDataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ namespace InfluxDB3.Client.Test.Write
{
[TestFixture]
[SuppressMessage("ReSharper", "ConditionIsAlwaysTrueOrFalse")]
[SuppressMessage("ReSharper", "EqualExpressionComparison")]
[SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")]
[SuppressMessage("Assertion", "NUnit2009:The same value has been provided as both the actual and the expected argument")]
public class PointDataTest
{
[Test]
Expand Down Expand Up @@ -591,9 +594,9 @@ public void FromValues()
.SetTag("location", "europe")
.SetField("a", 1)
.SetFloatField("b", 1124.456f)
.SetTimestamp(123L);
.SetTimestamp(DateTimeOffset.FromUnixTimeSeconds(15678));

Assert.That(PointData.FromValues(values).ToLineProtocol(), Is.EqualTo("h2o,location=europe a=1i,b=1124.456 123"));
Assert.That(PointData.FromValues(values).ToLineProtocol(), Is.EqualTo("h2o,location=europe a=1i,b=1124.456 15678000000000"));

var ae = Assert.Throws<Exception>(() =>
{
Expand All @@ -604,8 +607,46 @@ public void FromValues()

PointData.FromValues(pointDataValues);
});
Assert.That(ae, Is.Not.Null);
Assert.That(ae.Message, Is.EqualTo("Missing measurement!"));
}

[Test]
public void PointDataValuesAsPoint()
{
var values = PointDataValues
.Measurement("h2o")
.SetTag("location", "europe")
.SetField("a", 1)
.SetFloatField("b", 1124.456f)
.SetTimestamp(DateTimeOffset.FromUnixTimeSeconds(15678));

Assert.Multiple(() =>
{
Assert.That(values.AsPointData().ToLineProtocol(), Is.EqualTo("h2o,location=europe a=1i,b=1124.456 15678000000000"));
Assert.That(values.AsPointData("xyz").ToLineProtocol(), Is.EqualTo("xyz,location=europe a=1i,b=1124.456 15678000000000"));
});
}

[Test]
public void PointDataValuesEquals()
{
var values = PointDataValues
.Measurement("h2o")
.SetTag("location", "europe")
.SetField("a", 1)
.SetFloatField("b", 1124.456f)
.SetTimestamp(DateTimeOffset.FromUnixTimeSeconds(15678));

Assert.Multiple(() =>
{
Assert.That(values, Is.EqualTo(values));
Assert.That(values.Equals((object)values), Is.EqualTo(true));
Assert.That(values.Equals(null), Is.EqualTo(false));
Assert.That(values != values, Is.EqualTo(false));

Check warning on line 646 in Client.Test/Write/PointDataTest.cs

View workflow job for this annotation

GitHub Actions / CodeQL-Build

Comparison made to same variable; did you mean to compare something else?

Check warning on line 646 in Client.Test/Write/PointDataTest.cs

View workflow job for this annotation

GitHub Actions / CodeQL-Build

Comparison made to same variable; did you mean to compare something else?
Assert.That(values == values, Is.EqualTo(true));

Check warning on line 647 in Client.Test/Write/PointDataTest.cs

View workflow job for this annotation

GitHub Actions / CodeQL-Build

Comparison made to same variable; did you mean to compare something else?

Check warning on line 647 in Client.Test/Write/PointDataTest.cs

View workflow job for this annotation

GitHub Actions / CodeQL-Build

Comparison made to same variable; did you mean to compare something else?
});
}
}

internal class GenericObject
Expand Down

0 comments on commit 181caee

Please sign in to comment.