diff --git a/CSharpFunctionalExtensions.Tests/CSharpFunctionalExtensions.Tests.csproj b/CSharpFunctionalExtensions.Tests/CSharpFunctionalExtensions.Tests.csproj index dda8cbe1..f1606780 100644 --- a/CSharpFunctionalExtensions.Tests/CSharpFunctionalExtensions.Tests.csproj +++ b/CSharpFunctionalExtensions.Tests/CSharpFunctionalExtensions.Tests.csproj @@ -3,7 +3,6 @@ net8.0 0618 - true diff --git a/CSharpFunctionalExtensions.Tests/MaybeTests/DeserializationTests.cs b/CSharpFunctionalExtensions.Tests/MaybeTests/DeserializationTests.cs deleted file mode 100644 index 19bf99d5..00000000 --- a/CSharpFunctionalExtensions.Tests/MaybeTests/DeserializationTests.cs +++ /dev/null @@ -1,61 +0,0 @@ -using FluentAssertions; -using System; -using System.IO; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters.Binary; -using Xunit; - -namespace CSharpFunctionalExtensions.Tests.MaybeTests -{ - public class DeserializationTests - { - [Fact] - public void Deserialize_sets_no_value_on_maybe_none() - { - Maybe maybe = Maybe.None; - var serialized = Serialize(maybe); - - Maybe deserialized = Deserialize>(serialized); - - deserialized.HasValue.Should().BeFalse(); - deserialized.HasNoValue.Should().BeTrue(); - } - - [Fact] - public void Deserialize_sets_correct_value_on_maybe() - { - var instance = new MyClass(); - - Maybe maybe = instance; - var serialized = Serialize(maybe); - - Maybe deserialized = Deserialize>(serialized); - - deserialized.HasValue.Should().BeTrue(); - deserialized.HasNoValue.Should().BeFalse(); - deserialized.Value.Should().BeEquivalentTo(instance); - } - - private static Stream Serialize(object source) - { - IFormatter formatter = new BinaryFormatter(); - Stream stream = new MemoryStream(); - formatter.Serialize(stream, source); - return stream; - } - - private static T Deserialize(Stream stream) - { - IFormatter formatter = new BinaryFormatter(); - stream.Position = 0; - return (T)formatter.Deserialize(stream); - } - - [Serializable] - private class MyClass - { - public string String { get; set; } - public int Number { get; set; } - } - } -} \ No newline at end of file diff --git a/CSharpFunctionalExtensions.Tests/ResultTests/DeserializationTests.cs b/CSharpFunctionalExtensions.Tests/ResultTests/DeserializationTests.cs deleted file mode 100644 index 3d0f067a..00000000 --- a/CSharpFunctionalExtensions.Tests/ResultTests/DeserializationTests.cs +++ /dev/null @@ -1,118 +0,0 @@ -using FluentAssertions; -using System; -using System.IO; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters.Binary; -using Xunit; - -namespace CSharpFunctionalExtensions.Tests.ResultTests -{ - public class DeserializationTests - { - private static readonly string _errorMessage = "this failed"; - - [Fact] - public void Deserialize_sets_correct_statuses_on_success_result() - { - Result okResult = Result.Success(); - var serialized = Serialize(okResult); - - Result result = Deserialize(serialized); - - result.IsSuccess.Should().BeTrue(); - result.IsFailure.Should().BeFalse(); - } - - [Fact] - public void Deserialize_sets_correct_statuses_on_failure_result() - { - Result okResult = Result.Failure(_errorMessage); - var serialized = Serialize(okResult); - - Result result = Deserialize(serialized); - - result.IsSuccess.Should().BeFalse(); - result.IsFailure.Should().BeTrue(); - } - - [Fact] - public void Deserialize_adds_message_in_context_on_failure_result() - { - Result failResult = Result.Failure(_errorMessage); - var serialized = Serialize(failResult); - - Result result = Deserialize(serialized); - - result.Error.Should().Be(_errorMessage); - } - - [Fact] - public void Deserialize_of_generic_result_adds_object_in_context_when_success_result() - { - DeserializationTestObject language = new DeserializationTestObject { Number = 232, String = "C#" }; - Result failResult = Result.Success(language); - var serialized = Serialize(failResult); - - Result result = Deserialize>(serialized); - - result.Value.Should().BeEquivalentTo(language); - } - - [Fact] - public void Deserialize_adds_error_object_in_serialization_context_when_failure_result() - { - DeserializationTestObject errorObject = new DeserializationTestObject { Number = 500, String = "Error message" }; - Result failResult = Result.Failure(errorObject); - var serialized = Serialize(failResult); - - Result result = Deserialize>(serialized); - - result.Error.Should().BeEquivalentTo(errorObject); - } - - [Fact] - public void Deserialization_of_UnitResult_when_success() - { - UnitResult failResult = UnitResult.Success(); - var serialized = Serialize(failResult); - - UnitResult result = Deserialize>(serialized); - - result.IsSuccess.Should().Be(true); - } - - [Fact] - public void Deserialization_of_UnitResult_when_failure() - { - DeserializationTestObject errorObject = new DeserializationTestObject { Number = 500, String = "Error message" }; - UnitResult failResult = UnitResult.Failure(errorObject); - var serialized = Serialize(failResult); - - UnitResult result = Deserialize>(serialized); - - result.Error.Should().BeEquivalentTo(errorObject); - } - - private static Stream Serialize(object source) - { - IFormatter formatter = new BinaryFormatter(); - Stream stream = new MemoryStream(); - formatter.Serialize(stream, source); - return stream; - } - - private static T Deserialize(Stream stream) - { - IFormatter formatter = new BinaryFormatter(); - stream.Position = 0; - return (T)formatter.Deserialize(stream); - } - - [Serializable] - private class DeserializationTestObject - { - public string String { get; set; } - public int Number { get; set; } - } - } -} \ No newline at end of file