Skip to content

Commit

Permalink
Remove redundant type casts
Browse files Browse the repository at this point in the history
References #23
  • Loading branch information
andreashuber-lawo committed May 4, 2016
1 parent 755cc1f commit 011c374
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Lawo.EmberPlusSharpTest/Ember/EmberReaderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void LongOctetstringTest()
var header =
new byte[]
{
0x60, 0x81, (byte)(contents.Length + 3), (byte)InnerNumber.Octetstring, 0x81, (byte)contents.Length
0x60, 0x81, (byte)(contents.Length + 3), InnerNumber.Octetstring, 0x81, (byte)contents.Length
};

AssertDecodeContents(InnerNumber.Octetstring, contents, header, contents);
Expand Down
8 changes: 4 additions & 4 deletions Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ await GetS101MessageStreamAsync(GetPayload("UninterestingParameterResponse2.xml"
using (var providerClient = await providerClientTask)
using (var providerStream = providerClient.GetStream())
{
var providerReader = new S101Reader((ReadAsyncCallback)providerStream.ReadAsync);
var providerReader = new S101Reader(providerStream.ReadAsync);
var consumerTask = Consumer<SingleParameterRoot>.CreateAsync(consumerClient);

if (await providerReader.ReadAsync(CancellationToken.None))
Expand Down Expand Up @@ -1246,7 +1246,7 @@ public void Bug4815Test()
using (var providerClient = await providerClientTask)
using (var providerStream = providerClient.GetStream())
{
var providerReader = new S101Reader((ReadAsyncCallback)providerStream.ReadAsync);
var providerReader = new S101Reader(providerStream.ReadAsync);
var consumerTask = Consumer<EmptyZoneNodeRoot>.CreateAsync(consumerClient);
await ReadAndAssertEqualAsync(providerReader, "Request1.xml");

Expand Down Expand Up @@ -1309,7 +1309,7 @@ public void Bug5201Test()
using (var providerClient = await providerClientTask)
using (var providerStream = providerClient.GetStream())
{
var providerReader = new S101Reader((ReadAsyncCallback)providerStream.ReadAsync);
var providerReader = new S101Reader(providerStream.ReadAsync);
var consumerTask = Consumer<EmptyZoneNodeRoot>.CreateAsync(consumerClient);
await ReadAndAssertEqualAsync(providerReader, "Request1.xml");

Expand Down Expand Up @@ -2003,7 +2003,7 @@ private Task StreamTestCore(
}

var args =
new object[]
new[]
{
failFormat(GetFormat(intValue, isLittleEndian)),
0,
Expand Down
2 changes: 1 addition & 1 deletion Lawo.EmberPlusSharpTest/S101/CommunicationTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ protected static S101Client GetFakeClient(Stream messageStream, IS101Logger logg
protected static async Task<MemoryStream> GetS101MessageStreamAsync(byte[] payload)
{
var stream = new MemoryStream();
var writer = new S101Writer((WriteAsyncCallback)stream.WriteAsync);
var writer = new S101Writer(stream.WriteAsync);

using (var messageStream = await writer.WriteMessageAsync(EmberDataMessage, CancellationToken.None))
{
Expand Down
2 changes: 1 addition & 1 deletion Lawo.EmberPlusSharpTest/S101/CompatibilityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void MainTest()
}

output.Position = 0;
var reader = new S101Reader((ReadAsyncCallback)output.ReadAsync, 1024);
var reader = new S101Reader(output.ReadAsync, 1024);
Assert.IsTrue(await reader.ReadAsync(CancellationToken.None));
Assert.IsInstanceOfType(reader.Message.Command, typeof(EmberData));

Expand Down
6 changes: 3 additions & 3 deletions Lawo.EmberPlusSharpTest/S101/PerformanceComparison.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void S101ReadTest()

using (var stream = new MemoryStream())
{
var writer = new S101Writer((WriteAsyncCallback)stream.WriteAsync, 1024);
var writer = new S101Writer(stream.WriteAsync, 1024);

using (var payloadStream = await writer.WriteMessageAsync(EmberDataMessage, CancellationToken.None))
{
Expand Down Expand Up @@ -95,7 +95,7 @@ private static async Task TestS101ReaderAsync(byte[] message, int messageCount)

using (var stream = new MemoryStream(message))
{
var reader = new S101Reader((ReadAsyncCallback)stream.ReadAsync, 1024);
var reader = new S101Reader(stream.ReadAsync, 1024);

for (int index = 0; index < messageCount; ++index)
{
Expand Down Expand Up @@ -132,7 +132,7 @@ private static Task TestGlowOutput(byte[] block, int blockCount)
private static async Task TestS101WriterAsync(byte[] block, int blockCount)
{
var completed = Task.FromResult(false);
var writer = new S101Writer((WriteAsyncCallback)((b, o, c, t) => completed), 1024);
var writer = new S101Writer((b, o, c, t) => completed, 1024);

using (var payloadStream = await writer.WriteMessageAsync(EmberDataMessage, CancellationToken.None))
{
Expand Down
4 changes: 2 additions & 2 deletions Lawo.EmberPlusSharpTest/S101/S101ReaderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public void ExceptionTest()
{
new S101Reader((b, o, c, t) => Task.FromResult(0));

AssertThrow<ArgumentNullException>(() => new S101Reader((ReadAsyncCallback)null, 1));
AssertThrow<ArgumentNullException>(() => new S101Reader(null, 1));
AssertThrow<ArgumentOutOfRangeException>(() => new S101Reader((b, o, c, t) => Task.FromResult(0), 0));

using (var input = new MemoryStream(
new byte[] { 0xFE, 0x00, 0x0E, 0x01, 0x01, 0x94, 0xE4, 0xFF, 0xFE, 0x00, 0x0E, 0x02, 0x01, 0xFD, 0xDC, 0xCE, 0xFF }))
{
var reader = new S101Reader((ReadAsyncCallback)input.ReadAsync, 1);
var reader = new S101Reader(input.ReadAsync, 1);
AssertThrow<InvalidOperationException>(() => reader.Message.ToString());
AssertThrow<InvalidOperationException>(() => reader.Payload.ToString());
Assert.IsTrue(await reader.ReadAsync(CancellationToken.None));
Expand Down
6 changes: 3 additions & 3 deletions Lawo.EmberPlusSharpTest/S101/S101WriterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void PayloadTest()
// First we create a writer, which can be used to write multiple messages.
// We specify which methods are used to write encoded output and flush it plus the size the internal
// buffer should have.
var writer = new S101Writer((WriteAsyncCallback)encodedStream.WriteAsync);
var writer = new S101Writer(encodedStream.WriteAsync);

// Next we write the message. In return we get a Stream object for the payload.
using (var payloadStream =
Expand All @@ -146,7 +146,7 @@ await writer.WriteMessageAsync(writtenMessage, CancellationToken.None))

// First we create a reader, which can be used to read multiple messages.
// We specify which methods are used to read encoded input.
var reader = new S101Reader((ReadAsyncCallback)encodedStream.ReadAsync);
var reader = new S101Reader(encodedStream.ReadAsync);
Assert.IsTrue(await reader.ReadAsync(CancellationToken.None)); // Read the first message
var readMessage = reader.Message;

Expand Down Expand Up @@ -179,7 +179,7 @@ public void ExceptionTest()
{
new S101Writer((b, o, c, t) => Task.FromResult(false));

AssertThrow<ArgumentNullException>(() => new S101Writer((WriteAsyncCallback)null, 1));
AssertThrow<ArgumentNullException>(() => new S101Writer(null, 1));
AssertThrow<ArgumentOutOfRangeException>(
() => new S101Writer((b, o, c, t) => Task.FromResult(false), 0));

Expand Down
4 changes: 2 additions & 2 deletions LawoTest/ComponentModel/BindingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public void ExceptionTest()
AssertThrow<ArgumentNullException>(
() => TwoWayBinding.Create((IProperty<Source, string>)null, this.target.GetProperty(o => o.Property)).Dispose(),
() => TwoWayBinding.Create(this.source.GetProperty(o => o.Property), (IProperty<Target, string>)null).Dispose(),
() => TwoWayBinding.Create(this.source.GetProperty(o => o.Property), (Func<string, string>)null, this.target.GetProperty(o => o.Property), v => v).Dispose(),
() => TwoWayBinding.Create(this.source.GetProperty(o => o.Property), v => v, this.target.GetProperty(o => o.Property), (Func<string, string>)null).Dispose());
() => TwoWayBinding.Create(this.source.GetProperty(o => o.Property), null, this.target.GetProperty(o => o.Property), v => v).Dispose(),
() => TwoWayBinding.Create(this.source.GetProperty(o => o.Property), v => v, this.target.GetProperty(o => o.Property), null).Dispose());
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion LawoTest/ComponentModel/FilterHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void ExceptionTest()

AssertThrow<ArgumentNullException>(
() => ((ReadOnlyObservableCollection<int>)null).Filter(i => true, null),
() => empty.Filter((Predicate<int>)null, null));
() => empty.Filter(null, null));
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions LawoTest/IO/BufferTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void WriteTest()
// This covers the case where the written bytes are copied into the buffer in two chunks
using (var stream = new MemoryStream())
{
var writeBuffer = new WriteBuffer((WriteCallback)stream.Write, 1);
var writeBuffer = new WriteBuffer(stream.Write, 1);
writeBuffer.Write(originalBytes, 0, originalBytes.Length);
writeBuffer.Flush();
CollectionAssert.AreEqual(originalBytes, stream.ToArray());
Expand All @@ -131,7 +131,7 @@ public void WriteAsyncTest()
// This covers the case where the written bytes are copied into the buffer in two chunks
using (var stream = new MemoryStream())
{
var writeBuffer = new WriteBuffer((WriteAsyncCallback)stream.WriteAsync, 1);
var writeBuffer = new WriteBuffer(stream.WriteAsync, 1);
await writeBuffer.WriteAsync(bytes, 0, bytes.Length, CancellationToken.None);
await writeBuffer.FlushAsync(CancellationToken.None);
CollectionAssert.AreEqual(bytes, stream.ToArray());
Expand Down Expand Up @@ -183,7 +183,7 @@ await AssertThrowAsync<InvalidOperationException>(
() => writeBuffer.ReserveAsync(2, CancellationToken.None),
() => writeBuffer.WriteAsync(new byte[3], 0, 3, CancellationToken.None));

var asyncWriteBuffer = new WriteBuffer((WriteAsyncCallback)stream.WriteAsync, 1);
var asyncWriteBuffer = new WriteBuffer(stream.WriteAsync, 1);
asyncWriteBuffer[asyncWriteBuffer.Count++] = 42;
AssertThrow<InvalidOperationException>(() => asyncWriteBuffer.Flush());
asyncWriteBuffer[asyncWriteBuffer.Count++] = 42;
Expand Down
4 changes: 2 additions & 2 deletions LawoTest/IO/StreamHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public void ExceptionTest()
AsyncPump.Run(
async () =>
{
AssertThrow<ArgumentNullException>(() => StreamHelper.Fill((ReadCallback)null, new byte[1], 0, 1));
AssertThrow<ArgumentNullException>(() => StreamHelper.Fill(null, new byte[1], 0, 1));
await AssertThrowAsync<ArgumentNullException>(
() => StreamHelper.FillAsync((ReadAsyncCallback)null, new byte[1], 0, 1, CancellationToken.None));
() => StreamHelper.FillAsync(null, new byte[1], 0, 1, CancellationToken.None));
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion LawoTest/Threading/Tasks/TaskQueueTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void ExceptionTest()
var queue = new TaskQueue();

AssertThrow<ArgumentNullException>(
() => queue.Enqueue((Func<Task>)null),
() => queue.Enqueue(null),
() => queue.Enqueue((Func<Task<string>>)null));
}
}
Expand Down
2 changes: 1 addition & 1 deletion LawoTest/Threading/Tasks/TaskSingletonTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void ExceptionTest()
var queue = new TaskSingleton();

AssertThrow<ArgumentNullException>(
() => queue.Execute((Func<Task>)null),
() => queue.Execute(null),
() => queue.Execute((Func<Task<string>>)null));
}
}
Expand Down
2 changes: 1 addition & 1 deletion LawoTest/Threading/Tasks/WorkQueueTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void ExceptionTest()
var queue = new WorkQueue();

AssertThrow<ArgumentNullException>(
() => queue.Enqueue((Action)null),
() => queue.Enqueue(null),
() => queue.Enqueue((Func<string>)null));
}
}
Expand Down

0 comments on commit 011c374

Please sign in to comment.