public CreateStump ( |
||
contract | The contract used to create the Stump. | |
return |
public StumpContract CreateStump(StumpContract contract)
{
if (contract == null)
{
throw new ArgumentNullException("contract");
}
if (string.IsNullOrEmpty(contract.StumpId))
{
contract.StumpId = RandomGenerator.GenerateIdentifier();
}
if (this.StumpNameExists(contract.StumpName))
{
throw new ArgumentException(Resources.StumpNameUsedError);
}
var entity = ContractEntityBinding.CreateEntityFromContract(contract);
_dataAccess.StumpCreate(this.ServerId, entity, contract.OriginalRequest.GetBody(), contract.OriginalResponse.GetBody(), contract.Response.GetBody());
UnwrapAndAddStump(contract);
return contract;
}
public void StumpNameExists_WithExistantName_ReturnsTrue() { var contract = new StumpContract() { OriginalRequest = new RecordedRequest(Substitute.For<IStumpsHttpRequest>(), ContentDecoderHandling.DecodeNotRequired), OriginalResponse = new RecordedResponse(Substitute.For<IStumpsHttpResponse>(), ContentDecoderHandling.DecodeNotRequired), Response = new RecordedResponse(Substitute.For<IStumpsHttpResponse>(), ContentDecoderHandling.DecodeNotRequired), StumpCategory = "ABC", StumpId = "abc", StumpName = "StumpName" }; var instance = new StumpsServerInstance(Substitute.For<IServerFactory>(), _serverId, _dal); instance.CreateStump(contract); Assert.IsTrue(instance.StumpNameExists(contract.StumpName)); }