Post #25
53
Работаешь? А вот и не надо, ведь сегодня выходной!
Отдыхай с чистой совестью, а работа не волк – всегда можно найти и получше 😈
Отдыхай с чистой совестью, а работа не волк – всегда можно найти и получше 😈
C# @dimasshortposts
Showing posts older than #26 · Back to latest
var neo = new Person("Mr Anderson", new DateOnly(1980, 2, 1));
Console.WriteLine(neo);
public record Person(string FullName, DateOnly DateOfBirth);
var neoPerson = person with { FullName = "Neo" };
var personClass = new PersonClass("Laurence Fishburne", new DateOnly(0,1,1));
var morpheusPersonClass = new PersonClass("Morpheus", personClass.DateOfBirth);
public class PersonClass
{
public PersonClass(string fullName, DateOnly dateOfBirth)
{
FullName = fullName;
DateOfBirth = dateOfBirth;
}
public string FullName { get; }
public DateOnly DateOfBirth { get; }
}
public record Person(string FullName, DateOnly DateOfBirth);

dotnet new -i BenchmarkDotNet.Templates
public class Person
{
public string FirstName { get; set; } = default!;
public string SecondName { get; set; } = default! ;
}
var person = new Person
{
FirstName = "Mr",
SecondName = "Anderson"
};
var personText = JsonSerializer.Serialize(person);
[JsonSerializable(typeof(Person))]
public partial class PersonJsonContext: JsonSerializerContext
{
}
var personText = JsonSerializer.Serialize(person, PersonJsonContext.Default.Person);

<PackAsTool>true</PackAsTool>
<ToolCommandName>myname</ToolCommandName>
<PackageOutputPath>./nupkg</PackageOutputPath>

public NotificationService(
IUsersRepository usersRepository,
ISubscriptionsService subscriptionsService,
IDataBaseService dataBaseService,
IBusSystem busSystem)
Mock<IUsersRepository> usersRepositoryMock = new Mock<IUsersRepository>();
Mock<ISubscriptionsService> subscriptionsServiceMock = new Mock<ISubscriptionsService>();
Mock<IDataBaseService> dataBaseServiceMock = new Mock<IDataBaseService>();
Mock<IBusSystem> busSystemMock = new Mock<IBusSystem>();
NotificationService sut = new NotificationService(
usersRepositoryMock.Object,
subscriptionsServiceMock.Object,
dataBaseServiceMock.Object,
busSystemMock.Object);MockRepository mockRepository = new MockRepository(MockBehavior.Loose);
NotificationService sut = new NotificationService(
mockRepository.Create<IUsersRepository>().Object,
mockRepository.Create<ISubscriptionsService>().Object,
mockRepository.Create<IDataBaseService>().Object,
mockRepository.Create<IBusSystem>().Object);MockRepository mockRepository = new MockRepository(MockBehavior.Loose);
NotificationService sut = new NotificationService(
mockRepository.Create<IUsersRepository>(MockBehavior.Strict).Object,
mockRepository.Create<ISubscriptionsService>().Object,
mockRepository.Create<IDataBaseService>().Object,
mockRepository.Create<IBusSystem>().Object);
sut.Notify();
mockRepository.VerifyAll();
mockRepository.VerifyNoOtherCalls();var array = Array.Empty<int>();public static void ItIsNotEmpty<T>(
IEnumerable<T> value,
[CallerArgumentExpression("value")] string message = "")
{
if (!value.Any())
{
throw new ArgumentException("Sequence is empty", message);
}
}EnsureThat.ItIsNotEmpty(array);EnsureThat.ItIsNotEmpty(Array.Empty<int>());