Skip to content

Ported TCK and examples #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CopyrightWaivers.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright Statement for Contributions to the Reactive Streams Project
Copyright Statement for Contributions to the Reactive Streams Project
=====================================================================

I hereby represent that all present, past and future contributions I make to
Expand All @@ -20,3 +20,4 @@ github name | Real Name, Email Address used for git commits, Company
---------------+----------------------------------------------------------------------------
cconstantin | Chris Constantin, [email protected], Aligned Software Solutions, Inc.
viktorklang | Viktor Klang, [email protected], Lightbend, Inc.
Silv3rcircl3 | Marc Piechura, [email protected], Pulmokard GmbH
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### 0.0.0 - 10.06.2016

Paceholder for the build script
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ src\.nuget\NuGet.exe update -self

src\.nuget\NuGet.exe install FAKE -ConfigFile src\.nuget\Nuget.Config -OutputDirectory src\packages -ExcludeVersion -Version 4.16.1

src\.nuget\NuGet.exe install xunit.runner.console -ConfigFile src\.nuget\Nuget.Config -OutputDirectory src\packages\FAKE -ExcludeVersion -Version 2.0.0
src\.nuget\NuGet.exe install NUnit.ConsoleRunner -ConfigFile src\.nuget\Nuget.Config -OutputDirectory src\packages\FAKE -ExcludeVersion -Version 3.2.1

if not exist src\packages\SourceLink.Fake\tools\SourceLink.fsx (
src\.nuget\nuget.exe install SourceLink.Fake -ConfigFile src\.nuget\Nuget.Config -OutputDirectory src\packages -ExcludeVersion
Expand Down
25 changes: 14 additions & 11 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ let testOutput = "TestResults"

let nugetDir = binDir @@ "nuget"
let workingDir = binDir @@ "build"
let libDir = workingDir @@ @"lib\net40\"
let libDirPortable = workingDir @@ @"lib\portable-net45+netcore45\"
let libDir45 = workingDir @@ @"lib\net45\"
let nugetExe = FullName @"src\.nuget\NuGet.exe"
let slnFile = "./src/Reactive.Streams.sln"

Expand Down Expand Up @@ -104,8 +105,7 @@ Target "CopyOutput" <| fun _ ->
let src = "src" @@ project @@ @"bin/Release/"
let dst = binDir @@ project
CopyDir dst src allFiles
[ "Reactive.Streams"
]
[ "api/Reactive.Streams"; "tck/Reactive.Streams.TCK" ]
|> List.iter copyOutput

Target "BuildRelease" DoNothing
Expand All @@ -123,18 +123,18 @@ Target "CleanTests" <| fun _ ->
DeleteDir testOutput
//--------------------------------------------------------------------------------
// Run tests
open Fake.Testing

open XUnit2Helper
Target "RunTests" <| fun _ ->
let xunitTestAssemblies = !! "src/**/bin/Release/*.Tests.dll"
let nunitTestAssemblies = !! "src/**/bin/Release/*.Tests.dll"

mkdir testOutput

let xunitToolPath = findToolInSubPath "xunit.console.exe" "src/packages/xunit.runner.console*/tools"
printfn "Using XUnit runner: %s" xunitToolPath
xUnit2
(fun p -> { p with OutputDir = testOutput; ToolPath = xunitToolPath })
xunitTestAssemblies
let nunitToolPath = findToolInSubPath "nunit3-console.exe" "src/packages/FAKE/NUnit.ConsoleRunner/tools"
printfn "Using NUnit runner: %s" nunitToolPath
NUnit3
(fun p -> { p with ToolPath = nunitToolPath; ResultSpecs = [testOutput + "/TestResults.xml"] })
nunitTestAssemblies

//--------------------------------------------------------------------------------
// Nuget targets
Expand Down Expand Up @@ -238,12 +238,15 @@ let createNugetPackages _ =
Dependencies = dependencies })
nuspec

// Copy dll, pdb and xml to libdir = workingDir/lib/net45/
// Copy dll, pdb and xml to libdir = workingDir/lib/net4x/
let libDir = if project.Contains ".TCK" then libDir45 else libDirPortable
ensureDirectory libDir
!! (releaseDir @@ project + ".dll")
++ (releaseDir @@ project + ".pdb")
++ (releaseDir @@ project + ".xml")
++ (releaseDir @@ project + ".ExternalAnnotations.xml")
++ (releaseDir @@ "Reactive.Streams.Example.Unicast.dll")
++ (releaseDir @@ "Reactive.Streams.Example.Unicast.pdb")
|> CopyFiles libDir

// Copy all src-files (.cs and .fs files) to workingDir/src
Expand Down
Binary file modified src/.nuget/NuGet.exe
Binary file not shown.
39 changes: 38 additions & 1 deletion src/Reactive.Streams.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reactive.Streams", "Reactive.Streams\Reactive.Streams.csproj", "{68FBB4DF-6D83-4CF1-8105-A1D41912852F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reactive.Streams", "api\Reactive.Streams\Reactive.Streams.csproj", "{68FBB4DF-6D83-4CF1-8105-A1D41912852F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{97BE0CEB-2816-47E9-ABC3-78905582A882}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -20,6 +20,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{D389959C
..\build.sh = ..\build.sh
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reactive.Streams.TCK", "tck\Reactive.Streams.TCK\Reactive.Streams.TCK.csproj", "{7DBE1261-04EB-4DA7-9953-C8E8CCC49010}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reactive.Streams.TCK.Tests", "tck\Reactive.Streams.TCK.Tests\Reactive.Streams.TCK.Tests.csproj", "{0F1C51EB-3554-487F-8CE4-75CAAD2887F8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reactive.Streams.Example.Unicast", "examples\Reactive.Streams.Example.Unicast\Reactive.Streams.Example.Unicast.csproj", "{01737D0D-ED40-499B-A706-12BE9847491B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reactive.Streams.Example.Unicast.Tests", "examples\Reactive.Streams.Example.Unicast.Tests\Reactive.Streams.Example.Unicast.Tests.csproj", "{A69C5115-5E39-47ED-B8EF-83A342968999}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{47E4C672-A6E8-43FE-A03E-761BC4601F84}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tck", "tck", "{755FE80E-BE8C-4FC3-8ACD-CCB8338889D2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{6CCDDC32-BD9D-4767-BF9A-64275D330558}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -30,8 +44,31 @@ Global
{68FBB4DF-6D83-4CF1-8105-A1D41912852F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68FBB4DF-6D83-4CF1-8105-A1D41912852F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68FBB4DF-6D83-4CF1-8105-A1D41912852F}.Release|Any CPU.Build.0 = Release|Any CPU
{7DBE1261-04EB-4DA7-9953-C8E8CCC49010}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7DBE1261-04EB-4DA7-9953-C8E8CCC49010}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7DBE1261-04EB-4DA7-9953-C8E8CCC49010}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7DBE1261-04EB-4DA7-9953-C8E8CCC49010}.Release|Any CPU.Build.0 = Release|Any CPU
{0F1C51EB-3554-487F-8CE4-75CAAD2887F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F1C51EB-3554-487F-8CE4-75CAAD2887F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F1C51EB-3554-487F-8CE4-75CAAD2887F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F1C51EB-3554-487F-8CE4-75CAAD2887F8}.Release|Any CPU.Build.0 = Release|Any CPU
{01737D0D-ED40-499B-A706-12BE9847491B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01737D0D-ED40-499B-A706-12BE9847491B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01737D0D-ED40-499B-A706-12BE9847491B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01737D0D-ED40-499B-A706-12BE9847491B}.Release|Any CPU.Build.0 = Release|Any CPU
{A69C5115-5E39-47ED-B8EF-83A342968999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A69C5115-5E39-47ED-B8EF-83A342968999}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A69C5115-5E39-47ED-B8EF-83A342968999}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A69C5115-5E39-47ED-B8EF-83A342968999}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{68FBB4DF-6D83-4CF1-8105-A1D41912852F} = {47E4C672-A6E8-43FE-A03E-761BC4601F84}
{7DBE1261-04EB-4DA7-9953-C8E8CCC49010} = {755FE80E-BE8C-4FC3-8ACD-CCB8338889D2}
{0F1C51EB-3554-487F-8CE4-75CAAD2887F8} = {755FE80E-BE8C-4FC3-8ACD-CCB8338889D2}
{01737D0D-ED40-499B-A706-12BE9847491B} = {6CCDDC32-BD9D-4767-BF9A-64275D330558}
{A69C5115-5E39-47ED-B8EF-83A342968999} = {6CCDDC32-BD9D-4767-BF9A-64275D330558}
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions src/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
[assembly: AssemblyCompanyAttribute("Reactive Streams")]
[assembly: AssemblyCopyrightAttribute("CC0 1.0 Universal")]
[assembly: AssemblyTrademarkAttribute("")]
[assembly: AssemblyVersionAttribute("1.0.0.0")]
[assembly: AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: AssemblyVersionAttribute("0.0.0.0")]
[assembly: AssemblyFileVersionAttribute("0.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Reactive.Streams</RootNamespace>
<AssemblyName>Reactive.Streams</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand All @@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -29,14 +30,16 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<DocumentationFile>bin\Release\Reactive.Streams.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedAssemblyInfo.cs">
<Compile Include="..\..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="IProcessor.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Threading;
using NUnit.Framework;
using Reactive.Streams.TCK;
using Reactive.Streams.TCK.Support;

namespace Reactive.Streams.Example.Unicast.Tests
{
[TestFixture]
public class AsyncSubscriberTest : SubscriberBlackboxVerification<int?>
{
public AsyncSubscriberTest() : base(new TestEnvironment())
{
}

public override int? CreateElement(int element) => element;

public override ISubscriber<int?> CreateSubscriber() => new Suscriber();

private sealed class Suscriber : AsyncSubscriber<int?>
{
protected override bool WhenNext(int? element) => true;
}

[Test]
public void TestAccumulation()
{
var i = new AtomicCounterLong(0);
var latch = new CountdownEvent(1);
var subscriber = new AccSubscriber(i, latch);
new NumberIterablePublisher(0,10).Subscribe(subscriber);
latch.Wait(TimeSpan.FromMilliseconds(Environment.DefaultTimeoutMilliseconds*10));
Assert.AreEqual(45, i.Current);
}

private sealed class AccSubscriber : AsyncSubscriber<int?>
{
private readonly AtomicCounterLong _counter;
private readonly CountdownEvent _latch;
private long _acc;

public AccSubscriber(AtomicCounterLong counter, CountdownEvent latch)
{
_counter = counter;
_latch = latch;
}

protected override bool WhenNext(int? element)
{
// no need for null check, OnNext handles this case
_acc += element.Value;
return true;
}

protected override void WhenComplete()
{
_counter.GetAndAdd(_acc);
_latch.Signal();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using Reactive.Streams.TCK;

namespace Reactive.Streams.Example.Unicast.Tests
{
[TestFixture]
public class IterablePublisherTest : PublisherVerification<int?>
{
public IterablePublisherTest() : base(new TestEnvironment())
{
}

public override IPublisher<int?> CreatePublisher(long elements)
{
Assert.LessOrEqual(elements, MaxElementsFromPublisher);
return new NumberIterablePublisher(0, (int)elements);
}

public override IPublisher<int?> CreateFailedPublisher() => new FailedPublisher();

private sealed class FailedPublisher : AsyncIterablePublisher<int?>
{
public FailedPublisher() : base(new FailedEnumerable())
{
}

private sealed class FailedEnumerable : IEnumerable<int?>
{
public IEnumerator<int?> GetEnumerator()
{
throw new Exception("Error state signal!");
}

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}

public override long MaxElementsFromPublisher { get; } = int.MaxValue;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;

// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("Reactive.Streams.Example.Unicast.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Reactive.Streams.Example.Unicast.Tests")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]

// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("a69c5115-5e39-47ed-b8ef-83a342968999")]

// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading