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
{ | |
"mode": "All", | |
"policyRule": { | |
"if": { | |
"allOf": [ | |
{ | |
"field": "type", | |
"equals": "Microsoft.Storage/storageAccounts" | |
}, | |
{ |
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 async Task WhenXThenY( | |
IRepository<SomeEntity> repository, // For this to work, a TestServer must have been started and | |
// this IRepository must be the same instance that the Controller is going to use when processing the request | |
WebApiClient client, // This must be wrapping an HttpClient connected to the TestServer | |
ISomeExternalServiceGateway gateway // Must also be the same instance to be used by the Controller) | |
{ | |
var entityInRequiredState = CreateEntityInStateX(); | |
repository.GetById(entityInRequiredState.Id).Return(entityInRequiredState); | |
await client.Post($"controller/action/{entityInRequiredState.Id}"); | |
entityInRequiredState.ShouldBeInStateY(); |
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 IUnitOfWork : IDisposable | |
{ | |
void Add<T>(T newItem) where T : class; | |
IRepository<T> All<T>() where T : class; | |
void SaveChanges(); | |
} | |
public interface IRepository<T> : IQueryable<T> where T : class | |
{ | |
void Add(T newItem); |
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 void EntryPointForSomeUseCaseWhichPrincipalEntityIsBook(Guid id, string otherParam) | |
{ | |
using (var unitOfWork = unitOfWorkFactory.Create()) | |
{ | |
var book = unitOfWork.All<Book>().WithId(id); | |
book.DoSomething(otherParam); | |
uow.SaveChanges(); | |
} | |
} |
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
// Verify that a controller returns a redirect to a Single Action Controller | |
result.AssertIsRedirectToRoute().WithSingleActionController(typeof(ShowList)); |
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
// Verify that a Single Action Controller returns a View | |
var sut = new Some.Controllers.ShowList(with, its, dependencies); | |
var request = new ShowListRequest(); | |
var result = sut.Execute(request); | |
result.AssertIsView() | |
.WithName("_ListPartial") | |
.WithModel<ListViewModel>(p => | |
{ | |
p.Property1.Should().Be(1); |
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
// Create a link to SingleActionController | |
@Html.ActionLink("Link text", typeof(Type.Of.The.SingleActionController)) | |
// Create a link to SingleActionController with a request and attributes | |
@Html.ActionLink("Another link text", typeof(Type.Of.The.SingleActionController), | |
routeValues: new ShowListRequest | |
{ | |
Property1 = Model.Property1, | |
AnotherProperty = Model.AnotherProperty | |
}, |