This file contains hidden or 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
<select [(ngModel)]="myValue"> | |
<option *ngFor="let s of stuff" [value]="s.value">{{s.key}}</option> | |
</select> |
This file contains hidden or 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
protected T IsOK<T>(IActionResult result) => | |
Is<OkObjectResult, T>(result, HttpStatusCode.OK); | |
protected void IsNoContent(IActionResult result) => | |
Is<NoContentResult>(result, HttpStatusCode.NoContent); | |
protected void IsBadRequest(IActionResult result) => | |
Is<BadRequestResult>(result, HttpStatusCode.BadRequest); | |
protected void IsNotFound(IActionResult result) => |
This file contains hidden or 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 ControllerTestBase | |
{ | |
protected void Is<T>(IActionResult result, HttpStatusCode statusCode) where T : StatusCodeResult | |
{ | |
var r = result as T; | |
r.Should().NotBeNull(); | |
r.StatusCode.Should().Be((int)statusCode); | |
} | |
protected TPayload Is<TResult, TPayload>(IActionResult result, HttpStatusCode statusCode) where TResult : ObjectResult |
This file contains hidden or 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
// Copyright (c) .NET Foundation. All rights reserved. | |
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | |
using System.Threading.Tasks; | |
namespace Microsoft.AspNetCore.Mvc | |
{ | |
/// <summary> | |
/// Defines a contract that represents the result of an action method. | |
/// </summary> |
This file contains hidden or 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 static class ControllerExtensions | |
{ | |
public static InternalServerErrorResult InternalServerError(this Controller controller) | |
{ | |
return new InternalServerErrorResult(); | |
} | |
} |
This file contains hidden or 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 MyController: Controller | |
{ | |
public MyController(IComplexTypeService complexTypeService) | |
{ | |
_complexTypeService = complexTypeService; | |
} | |
[HttpPost("{id}")] | |
public async Task<IActionResult> AddComplexType(string id, [FromBody]ComplexType cType) | |
{ |
This file contains hidden or 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
RawCap.exe -f 127.0.0.1 dumpfile.pcap |
This file contains hidden or 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 MyServiceTests : TestBase | |
{ | |
[Fact(DisplayName = "CalculateDistance should get the addresses from the address service")] | |
public async Task CalculateDistance_LooksUpAddressesInAddressService() | |
{ | |
double expected = 15623.32944; | |
Mock.Mock<IAddressService>().SetupGet(x => x.GetAddress(It.IsAny<string>())).ReturnsAsync("123 Fake St, Duck, WV, 25063"); | |
Provide<IDistanceCalculationService, DistanceCalculationService>(); | |
var myService = Mock.Create<MyService>(); |
This file contains hidden or 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 MyServiceTests : TestBase | |
{ | |
[Fact(DisplayName = "CalculateDistance should get the addresses from the address service")] | |
public async Task CalculateDistance_LooksUpAddressesInAddressService() | |
{ | |
double expected = 15000; | |
Mock.Mock<IAddressService>().SetupGet(x => x.Address).Returns("123 Fake St, Duck, WV, 25063"); | |
Mock.Mock<IDistanceCalculationService>().Setup(x => x.CalculateDistance(It.IsAny<string>())).ReturnsAsync(expected); | |
var myService = Mock.Create<MyService>(); |
This file contains hidden or 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 TestBase : IDisposable | |
{ | |
public readonly AutoMock Mock; | |
public TestBase() | |
{ | |
Mock = AutoMock.GetLoose(); | |
} | |
public TImplementation Provide<TInterface, TImplementation>() | |
where TInterface : class |