Skip to content

Commit

Permalink
Fixed CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextm committed Apr 8, 2023
1 parent 8e9ad3f commit 37a97b8
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 43 deletions.
20 changes: 11 additions & 9 deletions Tests/CSharpCore/Unit/Messaging/ErrorExceptionTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@ public void ErrorException_SerializationTest()

// Act
// Serialize the original exception to a memory stream
using var memoryStream = new MemoryStream();
binaryFormatter.Serialize(memoryStream, originalException);
memoryStream.Position = 0;
using (var memoryStream = new MemoryStream())
{
binaryFormatter.Serialize(memoryStream, originalException);
memoryStream.Position = 0;

// Deserialize the memory stream back into an object
var deserializedException = (ErrorException)binaryFormatter.Deserialize(memoryStream);
// Deserialize the memory stream back into an object
var deserializedException = (ErrorException)binaryFormatter.Deserialize(memoryStream);

// Assert
Assert.NotNull(deserializedException);
Assert.Equal(originalException.Message, deserializedException.Message);
Assert.IsType<InvalidOperationException>(deserializedException.InnerException);
// Assert
Assert.NotNull(deserializedException);
Assert.Equal(originalException.Message, deserializedException.Message);
Assert.IsType<InvalidOperationException>(deserializedException.InnerException);
}
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,20 @@ public void MessageFactoryException_SerializationTest()

// Act
// Serialize the original exception to a memory stream
using var memoryStream = new MemoryStream();
binaryFormatter.Serialize(memoryStream, originalException);
memoryStream.Position = 0;

// Deserialize the memory stream back into an object
var deserializedException = (MessageFactoryException)binaryFormatter.Deserialize(memoryStream);

// Assert
Assert.NotNull(deserializedException);
Assert.Equal(originalException.Message, deserializedException.Message);
Assert.IsType<InvalidOperationException>(deserializedException.InnerException);
Assert.Equal(originalException.GetBytes(), deserializedException.GetBytes());
using (var memoryStream = new MemoryStream())
{
binaryFormatter.Serialize(memoryStream, originalException);
memoryStream.Position = 0;

// Deserialize the memory stream back into an object
var deserializedException = (MessageFactoryException)binaryFormatter.Deserialize(memoryStream);

// Assert
Assert.NotNull(deserializedException);
Assert.Equal(originalException.Message, deserializedException.Message);
Assert.IsType<InvalidOperationException>(deserializedException.InnerException);
Assert.Equal(originalException.GetBytes(), deserializedException.GetBytes());
}
}

[Fact]
Expand Down
22 changes: 12 additions & 10 deletions Tests/CSharpCore/Unit/Messaging/PortInUseExceptionTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,20 @@ public void PortInUseException_SerializationTest()

// Act
// Serialize the original exception to a memory stream
using var memoryStream = new MemoryStream();
binaryFormatter.Serialize(memoryStream, originalException);
memoryStream.Position = 0;
using (var memoryStream = new MemoryStream())
{
binaryFormatter.Serialize(memoryStream, originalException);
memoryStream.Position = 0;

// Deserialize the memory stream back into an object
var deserializedException = (PortInUseException)binaryFormatter.Deserialize(memoryStream);
// Deserialize the memory stream back into an object
var deserializedException = (PortInUseException)binaryFormatter.Deserialize(memoryStream);

// Assert
Assert.NotNull(deserializedException);
Assert.Equal(originalException.Message, deserializedException.Message);
Assert.IsType<InvalidOperationException>(deserializedException.InnerException);
Assert.Equal(originalException.Endpoint, deserializedException.Endpoint);
// Assert
Assert.NotNull(deserializedException);
Assert.Equal(originalException.Message, deserializedException.Message);
Assert.IsType<InvalidOperationException>(deserializedException.InnerException);
Assert.Equal(originalException.Endpoint, deserializedException.Endpoint);
}
}

[Fact]
Expand Down
26 changes: 14 additions & 12 deletions Tests/CSharpCore/Unit/Messaging/TimeoutExceptionTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,20 @@ public void TimeoutException_SerializationTest()

// Act
// Serialize the original exception to a memory stream
using var memoryStream = new MemoryStream();
binaryFormatter.Serialize(memoryStream, originalException);
memoryStream.Position = 0;

// Deserialize the memory stream back into an object
var deserializedException = (TimeoutException)binaryFormatter.Deserialize(memoryStream);

// Assert
Assert.NotNull(deserializedException);
Assert.Equal(originalException.Message, deserializedException.Message);
Assert.IsType<InvalidOperationException>(deserializedException.InnerException);
Assert.Equal(originalException.Timeout, deserializedException.Timeout);
using (var memoryStream = new MemoryStream())
{
binaryFormatter.Serialize(memoryStream, originalException);
memoryStream.Position = 0;

// Deserialize the memory stream back into an object
var deserializedException = (TimeoutException)binaryFormatter.Deserialize(memoryStream);

// Assert
Assert.NotNull(deserializedException);
Assert.Equal(originalException.Message, deserializedException.Message);
Assert.IsType<InvalidOperationException>(deserializedException.InnerException);
Assert.Equal(originalException.Timeout, deserializedException.Timeout);
}
}

[Fact]
Expand Down

0 comments on commit 37a97b8

Please sign in to comment.