diff --git a/src/SharpPulsar.Test.API/Schema/KeyValueSchemaTest.cs b/src/SharpPulsar.Test.API/Schema/KeyValueSchemaTest.cs index 912dba56..725338a8 100644 --- a/src/SharpPulsar.Test.API/Schema/KeyValueSchemaTest.cs +++ b/src/SharpPulsar.Test.API/Schema/KeyValueSchemaTest.cs @@ -264,7 +264,7 @@ public virtual void TestSeparatedKeyValueEncodingTypeSchemaEncodeAndDecode() try { keyValueSchema.Decode(encodeBytes); - Assert.True(false, "This method cannot be used under this SEPARATED encoding type"); + Assert.Fail("This method cannot be used under this SEPARATED encoding type"); } catch (SchemaSerializationException e) { diff --git a/src/SharpPulsar.Test/AutoClusterFailoverTest.cs b/src/SharpPulsar.Test/AutoClusterFailoverTest.cs index cc7152a5..16ae0086 100644 --- a/src/SharpPulsar.Test/AutoClusterFailoverTest.cs +++ b/src/SharpPulsar.Test/AutoClusterFailoverTest.cs @@ -17,7 +17,7 @@ public class AutoClusterFailoverTest : IAsyncLifetime private PulsarClient _client; private readonly ITestOutputHelper _output; - private TaskCompletionSource _tcs; + //private TaskCompletionSource _tcs; private PulsarSystem _system; private PulsarClientConfigBuilder _configBuilder; public AutoClusterFailoverTest(ITestOutputHelper output, PulsarFixture fixture) diff --git a/src/SharpPulsar.Test/GenericSchemaTest.cs b/src/SharpPulsar.Test/GenericSchemaTest.cs index 2ab26dac..f260e9fb 100644 --- a/src/SharpPulsar.Test/GenericSchemaTest.cs +++ b/src/SharpPulsar.Test/GenericSchemaTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text.Json; +using System.Text.Json.Serialization; using System.Threading.Tasks; using Avro.Generic; using SharpPulsar.Builder; @@ -85,7 +86,7 @@ private byte[] ToBytes(T obj) return null; return JsonSerializer.SerializeToUtf8Bytes(obj, - new JsonSerializerOptions { WriteIndented = false, IgnoreNullValues = true }); + new JsonSerializerOptions { WriteIndented = false, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull}); } // Convert a byte array to an Object diff --git a/src/SharpPulsar.Test/TableViewTests.cs b/src/SharpPulsar.Test/TableViewTests.cs index 4b51625d..cc7b140e 100644 --- a/src/SharpPulsar.Test/TableViewTests.cs +++ b/src/SharpPulsar.Test/TableViewTests.cs @@ -45,7 +45,7 @@ public async Task TestTableView() var count = 20; var keys = await PublishMessages(topic, count, false); - var tv = await _client.NewTableViewBuilder(ISchema.Bytes) + var tv = await _client.NewTableView(ISchema.Bytes) .Topic(topic) .AutoUpdatePartitionsInterval(TimeSpan.FromSeconds(60)) .CreateAsync(); @@ -83,7 +83,7 @@ public async Task TestTableViewUpdatePartitions() var count = 20; var keys = await PublishMessages(topic, count, false); - var tv = await _client.NewTableViewBuilder(ISchema.Bytes).Topic(topic) + var tv = await _client.NewTableView(ISchema.Bytes).Topic(topic) .AutoUpdatePartitionsInterval(TimeSpan.FromSeconds(5)).CreateAsync(); _output.WriteLine($"start tv size: {tv.Size}"); diff --git a/src/SharpPulsar.TimeUnit/TimeUnit.cs b/src/SharpPulsar.TimeUnit/TimeUnit.cs index 80822420..ccd68bf3 100644 --- a/src/SharpPulsar.TimeUnit/TimeUnit.cs +++ b/src/SharpPulsar.TimeUnit/TimeUnit.cs @@ -183,16 +183,16 @@ private TimeUnit(string value, Func excessNanos ) { - this.Value = value; - this._ToNanos = toNanos; - this._ToTicks = toTicks; - this._ToMicros = toMicros; - this._ToMillis = toMillis; - this._ToSeconds = toSeconds; - this._ToMinutes = toMinutes; - this._ToHours = toHours; - this._ToDays = toDays; - this._ExcessNanos = excessNanos; + Value = value; + _ToNanos = toNanos; + _ToTicks = toTicks; + _ToMicros = toMicros; + _ToMillis = toMillis; + _ToSeconds = toSeconds; + _ToMinutes = toMinutes; + _ToHours = toHours; + _ToDays = toDays; + _ExcessNanos = excessNanos; } #endregion @@ -208,7 +208,7 @@ public void Sleep(long timeout) { if (timeout > 0) { - long Milliseconds = this.ToMilliseconds(timeout); + long Milliseconds = ToMilliseconds(timeout); Thread.Sleep((int)Milliseconds); } } @@ -223,7 +223,7 @@ public void TimedJoin(Thread thread, long timeout) { if (timeout > 0) { - long Milliseconds = this.ToMilliseconds(timeout); + long Milliseconds = ToMilliseconds(timeout); thread.Join((int)Milliseconds); } } @@ -247,49 +247,49 @@ public void TimedWait(Object obj, long timeout) { if (timeout > 0) { - long Milliseconds = this.ToMilliseconds(timeout); + long Milliseconds = ToMilliseconds(timeout); Monitor.Wait(obj, (int)Milliseconds); } } public long ToNanoseconds(long duration) { - return this._ToNanos(duration); + return _ToNanos(duration); } public long ToTicks(long duration) { - return this._ToTicks(duration); + return _ToTicks(duration); } public long ToMicroseconds(long duration) { - return this._ToMicros(duration); + return _ToMicros(duration); } public long ToMilliseconds(long duration) { - return this._ToMillis(duration); + return _ToMillis(duration); } public long ToSeconds(long duration) { - return this._ToSeconds(duration); + return _ToSeconds(duration); } public long ToMinutes(long duration) { - return this._ToMinutes(duration); + return _ToMinutes(duration); } public long ToHours(long duration) { - return this._ToHours(duration); + return _ToHours(duration); } public long ToDays(long duration) { - return this._ToDays(duration); + return _ToDays(duration); } /// @@ -307,7 +307,7 @@ public long ToDays(long duration) /// positively overflow public long Convert(long sourceDuration, TimeUnit sourceUnit) { - switch (this.Value) + switch (Value) { case _DAYS: { @@ -343,36 +343,36 @@ public long Convert(long sourceDuration, TimeUnit sourceUnit) } default: { - throw new ArgumentException($"The time unit {this.Value} is unrecognized."); + throw new ArgumentException($"The time unit {Value} is unrecognized."); } } } - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (ReferenceEquals(this, obj)) { return true; } - if (obj == null || this.GetType() != obj.GetType()) + if (obj == null || GetType() != obj.GetType()) { return false; } - TimeUnit Other = (TimeUnit)obj; + TimeUnit? Other = (TimeUnit)obj; - return this.Value == Other.Value; + return Value == Other.Value; } public override string ToString() { - return this.Value; + return Value; } public override int GetHashCode() { - return Hashing.Hash(this.Value); + return Hashing.Hash(Value); } public static bool operator ==(TimeUnit left, TimeUnit right) @@ -407,7 +407,7 @@ public override int GetHashCode() /// The number of excess nanoseconds private int ExcessNanos(long duration, long milliseconds) { - return this._ExcessNanos(duration, milliseconds); + return _ExcessNanos(duration, milliseconds); } ///