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
namespace Example; | |
public class ApiKeyMiddleware | |
{ | |
private readonly RequestDelegate _next; | |
private const string APIKEY = "XApiKey"; | |
public ApiKeyMiddleware(RequestDelegate next) | |
{ |
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
namespace Example; | |
public class ApiKeyMiddleware | |
{ | |
private readonly RequestDelegate _next; | |
private const string APIKEY = "XApiKey"; | |
public ApiKeyMiddleware(RequestDelegate next) | |
{ |
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
namespace Example; | |
public class ApiKeyMiddleware | |
{ | |
private readonly RequestDelegate _next; | |
private const string APIKEY = "XApiKey"; | |
public ApiKeyMiddleware(RequestDelegate next) | |
{ |
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
using Xunit; | |
namespace DateTimeProvider.Test; | |
public class DateTimeExample | |
{ | |
[Fact] | |
public void ShouldReturnGoodMorning_WhenCurrentTimeIsMorning() | |
{ | |
var dateTimeExample = new DateTimeHardcodedExample(); |
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
namespace DateTimeProvider; | |
public interface IDateTimeProvider | |
{ | |
public DateTime Now { get; } | |
} |
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
using System; | |
using NSubstitute; | |
using Xunit; | |
namespace DateTimeProvider.Test; | |
public class DateTimeDependencyInjectionExampleTest | |
{ | |
private readonly IDateTimeProvider _dateTimeProvider = Substitute.For<IDateTimeProvider>(); | |
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
namespace DateTimeProvider; | |
public class DateTimeDependencyInjectionExample | |
{ | |
private readonly IDateTimeProvider _dateTimeProvider; | |
public DateTimeDependencyInjectionExample(IDateTimeProvider dateTimeProvider) | |
{ | |
_dateTimeProvider = dateTimeProvider; | |
} |
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 string GetCurrentTimeMessage() | |
{ | |
var currentTime = DateTime.Now; | |
return currentTime.Hour switch | |
{ | |
>= 8 and < 12 => "Good morning!", | |
< 18 => "Good afternoon!", | |
_ => "Good evening!" | |
}; | |
} |
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
example-custom-domain.tk |