LotusIsWorking
LotusIsWorking
CC#
Created by LotusIsWorking on 1/12/2023 in #help
❔ How do you properly register NLog with .NET 6?
What is the proper way to do it?
5 replies
CC#
Created by LotusIsWorking on 1/12/2023 in #help
❔ How do you properly register NLog with .NET 6?
// NLog: Setup NLog for Dependency injection
builder.Logging.ClearProviders();
builder.Logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
builder.Host.UseNLog();
// NLog: Setup NLog for Dependency injection
builder.Logging.ClearProviders();
builder.Logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
builder.Host.UseNLog();
5 replies
CC#
Created by LotusIsWorking on 11/10/2022 in #help
❔ Proper mocking for Unit Testing (NUnit)
[Test]
public async Task TargetServiceSetStartDateAsToday_EqualProcessTest()
{
var mockRepo = new Mock<IDateTime>();
mockRepo.Setup(x => x.Now).Returns(DateTime.UtcNow);
var rule = new TargetServiceSetStartDateAsToday(mockRepo.Object);
var command = GetCommandWithReferenceTarget();
await rule.ProcessAsync(command);
Assert.AreEqual(command.StartDate, DateOnly.FromDateTime(mockRepo.Object.Now));
}
[Test]
public async Task TargetServiceSetStartDateAsToday_EqualProcessTest()
{
var mockRepo = new Mock<IDateTime>();
mockRepo.Setup(x => x.Now).Returns(DateTime.UtcNow);
var rule = new TargetServiceSetStartDateAsToday(mockRepo.Object);
var command = GetCommandWithReferenceTarget();
await rule.ProcessAsync(command);
Assert.AreEqual(command.StartDate, DateOnly.FromDateTime(mockRepo.Object.Now));
}
4 replies
CC#
Created by LotusIsWorking on 11/10/2022 in #help
❔ Proper mocking for Unit Testing (NUnit)
Which test is better?
4 replies