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
# ASP.NET | |
# Build and test ASP.NET projects. | |
# Add steps that publish symbols, save build artifacts, deploy, and more: | |
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4 | |
trigger: | |
- master | |
pool: | |
vmImage: 'VS2017-Win2016' |
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
# Adventure Works SQL Database Project Build Configuration | |
trigger: | |
- master | |
pool: | |
vmImage: 'VS2017-Win2016' | |
variables: | |
solution: '**/*.sln' |
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
private void UploadFileContentsToBlobStorage(HttpContent httpContent) | |
{ | |
byte[] fileContentBytes = httpContent.ReadAsByteArrayAsync().Result; | |
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString")); | |
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); | |
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer"); | |
container.CreateIfNotExists(); container.SetPermissions(new BlobContainerPermissions |
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
/// <summary> Uploads an image file </summary> | |
/// <returns>IHttpActionResult.</returns> | |
[Route("api/file")] | |
[HttpPost] | |
public IHttpActionResult UploadImage() | |
{ | |
if (Request.Content.IsMimeMultipartContent() == false) | |
{ | |
throw new UnsupportedMediaTypeException("unsupported media type", null); | |
} |
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
[Fact] | |
public void GetClients_WhenCalledWithSqlLiteInMemoryDataContext_ReturnsExpectedResult() | |
{ | |
var connection = new SqliteConnection("DataSource=:memory:"); | |
connection.Open(); | |
try | |
{ | |
var sqlLiteDataContextOptions = new DbContextOptionsBuilder<EventDataContext>() | |
.UseSqlite(connection) |
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
[Fact] | |
public void GetClients_WhenCalledWithInMemoryDataContext_ReturnsExpectedResult() | |
{ | |
var inMemoryDataContextOptions = new DbContextOptionsBuilder<EventDataContext>() | |
.UseInMemoryDatabase(databaseName: "Test_With_In_Memory_Database") | |
.Options; | |
// NOTE: Because we will need to assert against known data, | |
// we need to seed the in-memory test database | |
// with the same context options as the unit test |
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
// GET: api/Clients | |
[HttpGet("") | |
public IActionResult GetClients() | |
{ | |
var result = _context.Clients.Select(client => new Client() | |
{ | |
ClientId = client.ClientId, | |
FirstName = client.FirstName, | |
LastName = client.LastName, | |
Appointments = client.Appointments |
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 EventDbContextFactory : IDbContextFactory<EventDataContext> | |
{ | |
public EventDataContext Create(DbContextFactoryOptions options) | |
{ | |
var builder = new DbContextOptionsBuilder<EventDataContext>(); | |
builder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=SampleApiDatabase;Trusted_Connection=True;"); | |
return new EventDataContext(builder.Options); | |
} | |
} |