Skip to content

Commit

Permalink
allow builder to override config
Browse files Browse the repository at this point in the history
  • Loading branch information
Nguyen Ngo committed Mar 16, 2018
1 parent 0818d8d commit ac414b4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
31 changes: 31 additions & 0 deletions PactNetMessages.Tests/PactMessageBuilderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;

namespace PactNetMessages.Tests
{
public class PactMessageBuilderTests
{
[Fact]
public void PactMessageBuilder_ReturnsDefaultConfig()
{
var defaultConfig = new PactConfig();
var builder = new PactMessageBuilder();

Assert.Equal(defaultConfig.PactDir, builder.pactConfig.PactDir);
}

[Fact]
public void PactMEssageBuilder_OverrideConfig()
{
var customConfig = new PactConfig();
customConfig.PactDir = "/customPactDir";

var builder = new PactMessageBuilder(customConfig);

Assert.Equal("/customPactDir", builder.pactConfig.PactDir);

}
}
}
15 changes: 12 additions & 3 deletions PactNetMessages/PactMessageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,25 @@ public class PactMessageBuilder : IPactMessageBuilder
{
private readonly IMockMq mockMq;

private readonly PactConfig pactConfig;
public readonly PactConfig pactConfig;

public string ConsumerName { get; private set; }

public string ProviderName { get; private set; }

internal PactMessageBuilder(PactConfig config, MockMq mq)
{
pactConfig = config;
mockMq = mq;
}
public PactMessageBuilder()
: this(new PactConfig(), new MockMq())
{
}

public PactMessageBuilder(PactConfig config)
: this(config, new MockMq())
{
pactConfig = new PactConfig();
mockMq = new MockMq();
}

public IPactMessageBuilder ServiceConsumer(string consumerName)
Expand Down

0 comments on commit ac414b4

Please sign in to comment.