Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add nunit testing foundation.

  • Loading branch information...
commit 7441025bd7f5a15cbe98071eda4143efb5b17a56 1 parent 97c1d6a
@atsushieno authored
View
13 Makefile
@@ -0,0 +1,13 @@
+
+RUNTIME = mono
+
+all: System.Reactive.Tests/bin/Debug/System.Reactive.Tests.dll
+
+System.Reactive/bin/Debug/System.Reactive.dll:
+ xbuild
+
+System.Reactive.Tests/bin/Debug/System.Reactive.Tests.dll: System.Reactive/bin/Debug/System.Reactive.dll
+ xbuild
+
+run-test: all
+ $(RUNTIME) external/nunit26/nunit-console.exe System.Reactive.Tests/bin/Debug/System.Reactive.Tests.dll
View
55 System.Reactive.Tests/System.Reactive.Tests.csproj
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>10.0.0</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4EF2BF6E-CF73-403B-8C08-753783CA7CCC}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <RootNamespace>System.Reactive.Tests</RootNamespace>
+ <AssemblyName>System.Reactive.Tests</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="nunit.core, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
+ <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <Folder Include="System\" />
+ <Folder Include="System.Reactive\" />
+ <Folder Include="System.Reactive.Concurrency\" />
+ <Folder Include="System.Reactive.Disposables\" />
+ <Folder Include="System.Reactive.Linq\" />
+ <Folder Include="System.Reactive.Subjects\" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="System\ObservableExtensionTest.cs" />
+ <Compile Include="System.Reactive\NotificationTest.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\System.Reactive\System.Reactive.csproj">
+ <Project>{0D7D238E-9FB4-4923-99EA-53CC34640235}</Project>
+ <Name>System.Reactive</Name>
+ </ProjectReference>
+ </ItemGroup>
+</Project>
View
29 System.Reactive.Tests/System.Reactive/NotificationTest.cs
@@ -0,0 +1,29 @@
+using System;
+using NUnit.Framework;
+using System.Reactive;
+
+namespace System.Reactive.Tests
+{
+ [TestFixture]
+ public class NotificationTest
+ {
+ [Test]
+ public void Kind ()
+ {
+ var n = Notification.CreateOnNext<int> (5);
+ Assert.AreEqual (NotificationKind.OnNext, n.Kind, "#1");
+ n = Notification.CreateOnError<int> (new Exception ("foobar"));
+ Assert.AreEqual (NotificationKind.OnError, n.Kind, "#2");
+ n = Notification.CreateOnCompleted<int> ();
+ Assert.AreEqual (NotificationKind.OnCompleted, n.Kind, "#3");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void CreateOnErrorNull ()
+ {
+ Notification.CreateOnError<int> (null);
+ }
+ }
+}
+
View
74 System.Reactive.Tests/System/ObservableExtensionTest.cs
@@ -0,0 +1,74 @@
+using System;
+using NUnit.Framework;
+using System.Reactive;
+using System.Reactive.Linq;
+
+namespace System.Reactive.Tests
+{
+ [TestFixture]
+ public class ObservableExtensionTest
+ {
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void SubscribeNullSource ()
+ {
+ ObservableExtensions.Subscribe<int> (null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void SubscribeSourceOnNextNullSource ()
+ {
+ ObservableExtensions.Subscribe<int> (null, (int v) => {});
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void SubscribeSourceOnErrorNullSource ()
+ {
+ ObservableExtensions.Subscribe<int> (null, v => {}, ex => {});
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void SubscribeSourceOnCompletedNullSource ()
+ {
+ ObservableExtensions.Subscribe<int> (null, (int v) => {}, () => {});
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void SubscribeAllNullSource ()
+ {
+ ObservableExtensions.Subscribe<int> (null, (int v) => {}, ex => {}, () => {});
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void SubscribeSourceOnNextNullOnNext ()
+ {
+ ObservableExtensions.Subscribe<int> (Observable.Never<int> (), null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void SubscribeSourceOnErrorNullOnError ()
+ {
+ ObservableExtensions.Subscribe<int> (Observable.Never<int> (), v => {}, (Action<Exception>) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void SubscribeSourceOnCompletedNullOnCompleted ()
+ {
+ ObservableExtensions.Subscribe<int> (Observable.Never<int> (), v => {}, (Action) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void SubscribeAllNullAllActions ()
+ {
+ ObservableExtensions.Subscribe<int> (Observable.Never<int> (), null, null, null);
+ }
+ }
+}
View
2  System.Reactive/System.Reactive.Linq/Observable.Events.cs
@@ -99,7 +99,7 @@ public static partial class Observable
throw new ArgumentNullException ("removeHandler");
/* FIXME: this is no-go, fails to bind for incompatible argument types (EventArgs vs. TEventArgs !) */
- ISubject<EventPattern<TEventArgs>> subject;
+ ISubject<EventPattern<TEventArgs>> subject = null;
Action<object, TEventArgs> d = delegate (object sender, TEventArgs args) { subject.OnNext (new EventPattern<TEventArgs> (sender, args)); };
Func<ISubject<EventPattern<TEventArgs>>, TDelegate> handlerCreator =
sub => { subject = sub; return (TDelegate) (object) Delegate.CreateDelegate (typeof (TDelegate), d.GetType ().GetMethod ("Invoke")); };
View
2  System.Reactive/System.Reactive.Linq/Observable.cs
@@ -1500,7 +1500,7 @@ public static IObservable<TSource> Retry<TSource> (this IObservable<TSource> sou
*/
var sub = new ReplaySubject<TSource> ();
- Action<Exception> onError;
+ Action<Exception> onError = null;
var dis = new List<IDisposable> ();
onError = (error) => {
if (retryCount-- <= 0)
View
2  System.Reactive/System.Reactive/Notification.Static.cs
@@ -12,6 +12,8 @@ public static Notification<T> CreateOnCompleted<T> ()
public static Notification<T> CreateOnError<T> (Exception error)
{
+ if (error == null)
+ throw new ArgumentNullException ("error");
return new Notification<T>.OnError (error);
}
View
8 System.Reactive/System/ObservableExtensions.cs
@@ -11,21 +11,29 @@ public static IDisposable Subscribe<TSource> (this IObservable<TSource> source)
public static IDisposable Subscribe<TSource> (this IObservable<TSource> source, Action<TSource> onNext)
{
+ if (source == null)
+ throw new ArgumentNullException ("source");
return source.Subscribe (Observer.Create (onNext));
}
public static IDisposable Subscribe<TSource> (this IObservable<TSource> source, Action<TSource> onNext, Action<Exception> onError)
{
+ if (source == null)
+ throw new ArgumentNullException ("source");
return source.Subscribe (Observer.Create (onNext, onError));
}
public static IDisposable Subscribe<TSource> (this IObservable<TSource> source, Action<TSource> onNext, Action onCompleted)
{
+ if (source == null)
+ throw new ArgumentNullException ("source");
return source.Subscribe (Observer.Create (onNext, onCompleted));
}
public static IDisposable Subscribe<TSource> (this IObservable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)
{
+ if (source == null)
+ throw new ArgumentNullException ("source");
return source.Subscribe (Observer.Create (onNext, onError, onCompleted));
}
}
View
13 external/nunit26/README.mono-reactive
@@ -0,0 +1,13 @@
+
+This is a directory for NUnit 2.6 (beta) files. See the project page for
+details and license.
+http://www.nunit.org/index.php?p=docHome&r=2.6
+
+(Note that I edited nunit-console.exe config slightly from the binary
+distribution.)
+
+You can either run "make" or open mono-reactive.sln in MonoDevelop and run
+System.Reactive.Tests.dll (as an NUnit test project).
+
+You can alternatively run nunit-console.exe on .NET Framework; just edit
+Makefile and add # prefix to "RUNTIME = mono" line to comment it out.
View
BIN  external/nunit26/nunit-console-runner.dll
Binary file not shown
View
BIN  external/nunit26/nunit-console.exe
Binary file not shown
View
31 external/nunit26/nunit-console.exe.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <!--
+ The .NET 2.0 build of the console runner only
+ runs under .NET 2.0 or higher. The setting
+ useLegacyV2RuntimeActivationPolicy only applies
+ under .NET 4.0 and permits use of mixed mode
+ assemblies, which would otherwise not load
+ correctly.
+ -->
+ <startup useLegacyV2RuntimeActivationPolicy="true">
+ <!-- Comment out the next line to force use of .NET 4.0 -->
+ <!-- supportedRuntime version="v2.0.50727" / -->
+ <supportedRuntime version="v4.0.30319" />
+ </startup>
+
+ <runtime>
+ <!-- Ensure that test exceptions don't crash NUnit -->
+ <legacyUnhandledExceptionPolicy enabled="1" />
+
+ <!-- Run partial trust V2 assemblies in full trust under .NET 4.0 -->
+ <loadFromRemoteSources enabled="true" />
+
+ <!-- Look for addins in the addins directory for now -->
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <probing privatePath="lib;addins"/>
+ </assemblyBinding>
+
+ </runtime>
+
+</configuration>
View
BIN  external/nunit26/nunit.core.dll
Binary file not shown
View
BIN  external/nunit26/nunit.core.interfaces.dll
Binary file not shown
View
BIN  external/nunit26/nunit.framework.dll
Binary file not shown
View
BIN  external/nunit26/nunit.util.dll
Binary file not shown
View
29 mono-reactive.sln
@@ -0,0 +1,29 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Reactive", "System.Reactive\System.Reactive.csproj", "{0D7D238E-9FB4-4923-99EA-53CC34640235}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Reactive.Tests", "System.Reactive.Tests\System.Reactive.Tests.csproj", "{4EF2BF6E-CF73-403B-8C08-753783CA7CCC}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {0D7D238E-9FB4-4923-99EA-53CC34640235}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0D7D238E-9FB4-4923-99EA-53CC34640235}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0D7D238E-9FB4-4923-99EA-53CC34640235}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0D7D238E-9FB4-4923-99EA-53CC34640235}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4EF2BF6E-CF73-403B-8C08-753783CA7CCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4EF2BF6E-CF73-403B-8C08-753783CA7CCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4EF2BF6E-CF73-403B-8C08-753783CA7CCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4EF2BF6E-CF73-403B-8C08-753783CA7CCC}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = System.Reactive\System.Reactive.csproj
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Please sign in to comment.
Something went wrong with that request. Please try again.