Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Commit

Permalink
Writer test adjustment. #15
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-E-angelo committed Jun 15, 2019
1 parent 816ea3d commit 25f4193
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
15 changes: 13 additions & 2 deletions Super.Serialization.Testing.Application/StagedWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,28 @@ async Task Verify()
{
using (var stream = new MemoryStream())
{
await new SingleStagedWriter<uint>(PositiveNumber.Default).Get(new Input<uint>(stream, 12345u));
await new SingleStageWriter<uint>(PositiveNumber.Default).Get(new Input<uint>(stream, 12345u));
stream.ToArray().Should().Equal(JsonSerializer.ToUtf8Bytes(12345u));
}
}

[Fact]
public async Task VerifyNativeAssumption()
{
const uint parameter = 12345u;
using (var stream = new MemoryStream())
{
await JsonSerializer.WriteAsync(parameter, stream);
stream.ToArray().Should().Equal(JsonSerializer.ToUtf8Bytes(parameter));
}
}

public class Benchmarks
{
readonly IStagedWriter<uint> _writer;
readonly uint _data;

public Benchmarks() : this(new SingleStagedWriter<uint>(PositiveNumber.Default), 12345u) {}
public Benchmarks() : this(new SingleStageWriter<uint>(PositiveNumber.Default), 12345u) {}

public Benchmarks(IStagedWriter<uint> writer, uint data)
{
Expand Down
15 changes: 1 addition & 14 deletions Super.Serialization.Testing.Application/WriterTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using BenchmarkDotNet.Attributes;
using FluentAssertions;
using System.IO;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Xunit;

namespace Super.Serialization.Testing.Application
Expand All @@ -24,17 +22,6 @@ public void Simple()
.Be(expected);
}

[Fact]
public async Task Measure()
{
const uint parameter = 12345u;
using (var stream = new MemoryStream())
{
await JsonSerializer.WriteAsync(parameter, stream);
stream.ToArray().Should().Equal(JsonSerializer.ToUtf8Bytes(parameter));
}
}

/*sealed class Value
{
public Value(uint number) => Number = number;
Expand All @@ -54,7 +41,7 @@ public class Benchmarks
readonly IWriter<uint> _writer;
readonly uint _data;

public Benchmarks() : this(Writer.Default, 12345) {}
public Benchmarks() : this(Writer.Default, 12345u) {}

public Benchmarks(IWriter<uint> writer, uint data)
{
Expand Down
6 changes: 3 additions & 3 deletions Super.Serialization/Writer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ public void Execute(Composition parameter)

public interface IStagedWriter<T> : ISelect<Input<T>, Task> {}

public sealed class SingleStagedWriter<T> : IStagedWriter<T>
public sealed class SingleStageWriter<T> : IStagedWriter<T>
{
readonly IEmit<T> _instruction;
readonly ICompositor<T> _compositor;

public SingleStagedWriter(IEmit<T> instruction) : this(instruction, Compositor<T>.Default) {}
public SingleStageWriter(IEmit<T> instruction) : this(instruction, Compositor<T>.Default) {}

public SingleStagedWriter(IEmit<T> instruction, ICompositor<T> compositor)
public SingleStageWriter(IEmit<T> instruction, ICompositor<T> compositor)
{
_instruction = instruction;
_compositor = compositor;
Expand Down

0 comments on commit 25f4193

Please sign in to comment.