This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> | |
<system.webServer> | |
<urlCompression xdt:Transform="Remove" /> | |
<urlCompression doStaticCompression="false" doDynamicCompression="false" xdt:Transform="InsertIfMissing" /> | |
</system.webServer> | |
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[FunctionName("TopicProcessor")] | |
public static async Task Run( | |
[ServiceBusTrigger("%topic-name%", "%subscription-name%", AccessRights.Manage, Connection = "connection")] BrokeredMessage msg, | |
[ServiceBus("%topic-name%", AccessRights.Manage, Connection = "connection", EntityType = EntityType.Topic)] IAsyncCollector<BrokeredMessage> outputTopic, | |
ILogger log) | |
{ | |
var thing = msg.GetBody<Thing>(); | |
try { | |
var apiClient = new ApiClient(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var message = ReceiveMessageFromTopic(); | |
try { | |
//run the code within your function, passing the message as a parameter | |
RunFunctionCode(message); | |
} | |
catch() { | |
message.Abandon(); | |
} | |
message.Complete(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[FunctionName("TopicProcessor")] | |
public static async Task Run( | |
[ServiceBusTrigger("%topic-name%", "%subscription-name%", AccessRights.Manage, Connection = "connection")] BrokeredMessage msg, | |
ILogger log) | |
{ | |
var thing = msg.GetBody<Thing>(); | |
var apiClient = new ApiClient(); | |
try { | |
await apiClient.PostAsync(thing); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[FunctionName("TopicProcessor")] | |
public static async Task Run( | |
[ServiceBusTrigger("%topic-name%", "%subscription-name%", AccessRights.Manage, Connection = "connection")] BrokeredMessage msg, | |
ILogger log) | |
{ | |
var thing = msg.GetBody<Thing>(); | |
var apiClient = new ApiClient(); | |
await apiClient.PostAsync(thing); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Arrange | |
var mockCustomerService = new Mock(); | |
var customerController = new CustomerController(mockCustomerService.Object); | |
Customer customerServiceSaveArg = null; | |
mockCustomerService | |
.Setup(x => x.Save(It.IsAny())) | |
.Returns(1) | |
.Callback(c => customerServiceSaveArg = c); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var customer = new Customer(); | |
customer.FirstName = firstName; | |
customer.LastName = firstName; //uh oh! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Arrange | |
var mockCustomerService = new Mock(); | |
var customerController = new CustomerController(mock.Object); | |
mockCustomerService.Setup(x=> x.Save(It.IsAny()) | |
.Returns(1); | |
//Act | |
customerController.Post("Alex", "Brown"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ICustomerService | |
{ | |
int Save(Customer customer); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomerController : Controller | |
{ | |
private ICustomerService _customerService; | |
public CustomerController(ICustomerService customerService) | |
{ | |
_customerService = customerService; | |
} | |
public IActionResult Post(string firstName, string lastName) |