public class ProductsImposter : IImposter | |
{ | |
public Imposter Build() | |
{ | |
return new ImposterDefinition("ProductsMock") | |
.DeclareResource("/api/Products", HttpMethod.Post) | |
.When(r => r.Content.Contains("Name:Test product")) | |
.Then(new ProductResponseCreator()) | |
.Build(); | |
} | |
} | |
public class ProductResponseCreator: IResponseCreator | |
{ | |
public Response CreateResponse() | |
{ | |
var productCreatedResponse = new ProductCreatedResponse | |
{ | |
Message = "Product created.", | |
ProductId = (uint)new Random().Next(int.MaxValue) | |
}; | |
return new ResponseBuilder().WithContent(productCreatedResponse, new JsonContentSerializer()) | |
.WithStatusCode(HttpStatusCode.Created) | |
.Build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment