.net-core

.NET core write better unit tests with Xunit + Autofixture + Moq

自闭症网瘾萝莉.ら 提交于 2020-12-13 07:02:46
问题 In .NET Core for unit testing, I'm using Xunit, Moq, and Autofixture. But even with them, I see that my unit tests become complicated and take time. Maybe someone could tell me if there are any ways to make this test smaller? [Fact] public async Task Verify_NotAuthorised_NoServiceSendInvoked() { // Arrange var fixture = new Fixture() .Customize(new AutoMoqCustomization()); var sut = fixture.Create<VerificationService>(); var mockApiBuilder = fixture.Freeze<Mock<IApiEntityBuilder>>(); //init

Is it possible to change colors in serilog?

一世执手 提交于 2020-12-13 04:51:41
问题 I have just integrated Serilog in my dot net core project. It is working really well but I use a dark theme and some logs are really dificult to read. As an example: This is how I init Serilog: string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); LoggerConfiguration loggerConfig = new LoggerConfiguration(); if (environment == "Production") loggerConfig.MinimumLevel.Information(); loggerConfig.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)

Is it possible to change colors in serilog?

孤人 提交于 2020-12-13 04:51:36
问题 I have just integrated Serilog in my dot net core project. It is working really well but I use a dark theme and some logs are really dificult to read. As an example: This is how I init Serilog: string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); LoggerConfiguration loggerConfig = new LoggerConfiguration(); if (environment == "Production") loggerConfig.MinimumLevel.Information(); loggerConfig.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)

Reading connection string placed in ASP.NET Core from class library. Database First

只谈情不闲聊 提交于 2020-12-13 04:34:25
问题 The structure of projects looks like this: Cars (ASP.NET Core MVC. Here we have a connection string ) Cars.Persistence (ASP.NET Core Class library. Here we have Repository, Database First) I've created a Model by the following command from this msdn docs: Scaffold-DbContext "Server=PC\SQL2014XP;Database=Cars;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models So far so good. However, now carsContext has hard coded connection string in Cars.Persistence - ASP.NET

Reading connection string placed in ASP.NET Core from class library. Database First

人走茶凉 提交于 2020-12-13 04:34:25
问题 The structure of projects looks like this: Cars (ASP.NET Core MVC. Here we have a connection string ) Cars.Persistence (ASP.NET Core Class library. Here we have Repository, Database First) I've created a Model by the following command from this msdn docs: Scaffold-DbContext "Server=PC\SQL2014XP;Database=Cars;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models So far so good. However, now carsContext has hard coded connection string in Cars.Persistence - ASP.NET

Razor email templates in .net standard 2.1 / Core 3.1

萝らか妹 提交于 2020-12-13 03:44:06
问题 I want to create a separate service for sending emails, this will be based on a .net core 3.1 application with its default layers (application, domain, contracts, infrastructure) Within this project, I want to create a create a class library which holds my Razor templates and parses them so the application layer can send this as an email (both HTML and non-html) after the model has been applied, however this is where i run into a problem. Every example i can find targets older .net core

How I can see the Async state machine (async/await under the hood) with the help of DotPeek?

巧了我就是萌 提交于 2020-12-13 03:30:17
问题 I'm watching a video lesson, where the author talking about async/await under the hood. He shows prepared and decompiled code. I want to do the same from scratch. I mean, decompile some C# compiled file with the help of, from example, DotPeek. So I have the following simple example: class Program { public static async Task KekAsync() { Console.WriteLine("Current thread id before await {0}", Thread.CurrentThread.ManagedThreadId); await Task.Delay(200); Console.WriteLine("Current thread id

Net Core: Entity Framework and SQL Server Temporal Tables, Automatic Scaffolding

你说的曾经没有我的故事 提交于 2020-12-13 03:17:07
问题 We are having issues using Entity Framework Core 2.2 with SQL Server temporal SystemVersioningTables. The following resolve issues with Entity Framework and system versioning columns. entityframework core and sql 2016 temporal tables Using the solution, is there a way for Entity Framework Core 2.2 to automatically add DatabaseGeneratedOption.Computed or OnModelCreating on SystemVersioning columns? Is there a command parameter in dotnet ef dbcontext scaffold ? We are seeking a way to

System.Numerics.Vector<T> Initialization Performance on .NET Framework

不羁岁月 提交于 2020-12-13 03:16:49
问题 System.Numerics.Vector brings SIMD support to .NET Core and .NET Framework. It works on .NET Framework 4.6+ and .NET Core. // Baseline public void SimpleSumArray() { for (int i = 0; i < left.Length; i++) results[i] = left[i] + right[i]; } // Using Vector<T> for SIMD support public void SimpleSumVectors() { int ceiling = left.Length / floatSlots * floatSlots; for (int i = 0; i < ceiling; i += floatSlots) { Vector<float> v1 = new Vector<float>(left, i); Vector<float> v2 = new Vector<float>

Entity Framework Core 3.1 with Temporal Tables - Access SysStartTime and SysEndTime

家住魔仙堡 提交于 2020-12-13 03:13:35
问题 I have created temporal tables based on Microsoft SQL Docs Creating a temporal table with a default history table . https://docs.microsoft.com/en-us/sql/relational-databases/tables/creating-a-system-versioned-temporal-table?view=sql-server-ver15#creating-a-temporal-table-with-a-default-history-table Migration: public partial class Temporaltables : Migration { List<string> tablesToUpdate = new List<string> { "Images", "Languages", "Questions", "Texts", "Medias", }; protected override void Up