Skip to content

Commit

Permalink
Merge pull request #145 from Particular/develop
Browse files Browse the repository at this point in the history
Switch to release flow
  • Loading branch information
danielmarbach authored Aug 7, 2019
2 parents a52ec31 + e49c744 commit d1846fc
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 8 deletions.
2 changes: 0 additions & 2 deletions CODEOWNERS

This file was deleted.

1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
For information on contributing, see https://docs.particular.net/platform/contributing.
9 changes: 6 additions & 3 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
assembly-versioning-scheme: Major
next-version: 7.0
next-version: 1.0
branches:
develop:
master:
mode: ContinuousDeployment
tag: alpha
increment: Minor
tracks-release-branches: true
release:
tag: rc
tag: ''
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ If you do not agree to these terms, do not access the NServiceBus code.

Your license to the NServiceBus source and/or binaries is governed by the Reciprocal Public License 1.5 (RPL1.5) license as described here:

http://www.opensource.org/licenses/rpl1.5.txt
https://www.opensource.org/licenses/rpl1.5.txt

If you do not wish to release the source of software you build using NServiceBus, you may use NServiceBus source and/or binaries under the License Agreement described here:

http://particular.net/LicenseAgreement
https://particular.net/LicenseAgreement
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ namespace NServiceBus.Testing
public void Register<T>(params T[] instance)
where T : class { }
public void Register<T>(System.Func<T> factory) { }
public void Register(System.Type type, System.Func<object> factory) { }
public void Register<T>(System.Func<T[]> factory)
where T : class { }
public void Register(System.Type type, System.Func<object[]> factory) { }
public virtual void Release(object instance) { }
}
public class Handler<T>
Expand Down
72 changes: 72 additions & 0 deletions src/NServiceBus.Testing.Tests/FakeBuilderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
namespace NServiceBus.Testing.Tests
{
using NUnit.Framework;

[TestFixture]
public class FakeBuilderTests
{
[Test]
public void ShouldResolveRegisteredFuncs()
{
var builder = new FakeBuilder();

var instance = new SomeClass();

builder.Register(()=> instance);

Assert.AreSame(instance, builder.Build<SomeClass>());
}

[Test]
public void ShouldResolveRegisteredFuncArrays()
{
var builder = new FakeBuilder();

var instance = new SomeClass();
var instance2 = new SomeClass();

builder.Register(() => new []
{
instance,
instance2
});

CollectionAssert.Contains(builder.BuildAll<SomeClass>(), instance);
CollectionAssert.Contains(builder.BuildAll<SomeClass>(), instance2);
}

[Test]
public void ShouldResolveRegisteredObjectFuncs()
{
var builder = new FakeBuilder();

object instance = new SomeClass();

builder.Register(typeof(SomeClass),() => instance);

Assert.AreSame(instance, builder.Build<SomeClass>());
}

[Test]
public void ShouldResolveRegisteredObjectFuncArrays()
{
var builder = new FakeBuilder();

var instance = new SomeClass();
var instance2 = new SomeClass();

builder.Register(typeof(SomeClass), () => new object[]
{
instance,
instance2
});

CollectionAssert.Contains(builder.BuildAll<SomeClass>(), instance);
CollectionAssert.Contains(builder.BuildAll<SomeClass>(), instance2);
}

class SomeClass
{
}
}
}
19 changes: 19 additions & 0 deletions src/NServiceBus.Testing/NSB.Testing.Fakes/FakeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ public void Register<T>(Func<T> factory)
});
}

/// <summary>
/// Registers a factory method which will be invoked every time an instance of <paramref name="type"/> is resolved.
/// </summary>
public void Register(Type type, Func<object> factory)
{
factories.Add(type, () => new []
{
factory()
});
}

/// <summary>
/// Registers a factory method which will be invoked every time an instance of <typeparamref name="T" /> is resolved.
/// </summary>
Expand All @@ -148,6 +159,14 @@ public void Register<T>(Func<T[]> factory) where T : class
factories.Add(typeof(T), factory);
}

/// <summary>
/// Registers a factory method which will be invoked every time an instance of <paramref name="type"/> is resolved.
/// </summary>
public void Register(Type type, Func<object[]> factory)
{
factories.Add(type, factory);
}

Dictionary<Type, Func<object[]>> factories = new Dictionary<Type, Func<object[]>>();

Dictionary<Type, object[]> instances = new Dictionary<Type, object[]>();
Expand Down
2 changes: 1 addition & 1 deletion src/NServiceBus.Testing/NServiceBus.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReference Include="NServiceBus" Version="[7.0.0, 8.0.0)" />
<PackageReference Include="Obsolete.Fody" Version="4.3.2" PrivateAssets="All" />
<PackageReference Include="Particular.CodeRules" Version="0.2.1" PrivateAssets="All" />
<PackageReference Include="Particular.Packaging" Version="0.2.1" PrivateAssets="All" />
<PackageReference Include="Particular.Packaging" Version="0.3.0" PrivateAssets="All" />
</ItemGroup>

</Project>

0 comments on commit d1846fc

Please sign in to comment.