Skip to content

Init commit#54

Open
IgnatSergeev wants to merge 10 commits intomainfrom
nunit
Open

Init commit#54
IgnatSergeev wants to merge 10 commits intomainfrom
nunit

Conversation

@IgnatSergeev
Copy link
Owner

@IgnatSergeev IgnatSergeev commented Nov 23, 2023

От одногрупника поступило предложение потренить функциональное мышление используя linq по возможности, так что тут я поставил челендж написать все без единого цикла

@YuriUfimtsev
Copy link

От одногрупника поступило предложение потренить функциональное мышление используя linq по возможности, так что тут я поставил челендж написать все без единого цикла

Идея хорошая, что с реализацией?

@IgnatSergeev
Copy link
Owner Author

IgnatSergeev commented Dec 21, 2023

От одногрупника поступило предложение потренить функциональное мышление используя linq по возможности, так что тут я поставил челендж написать все без единого цикла

Идея хорошая, что с реализацией?

Это бред, по воспоминаниям я писал коммент, когда и доделал задачу(это подразумевает пуш), но я не запушил, извиняюсь
P S ещё к тому же почему то тесты отсутствуют
P P S ещё и TestClass.cs не собирается
P P P S но возможно я тесты тогда не доделал(уже непомню, это было больше двух недель назад)

/// Test method attribute
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class Test : Attribute

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Один файл -- один класс. И название каждого атрибута должно словом Attribute заканчиваться. Например, BeforeAttribute

[AttributeUsage(AttributeTargets.Method)]
public class Test : Attribute
{
/// <summary>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужны конструкторы

Console.WriteLine("Incorrect argument, should be project assembly(binary or dll) path");
}

var assembly = Assembly.LoadFile(args[0]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не, в условии же по переданному пути может находиться несколько сборок

/// <summary>
/// Successful run result implementation
/// </summary>
public class OkResult : RunResult

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут в классах Result компилятор ругается на то, что не переопределяется метод Equals

namespace MyNUnit;

public class TestResultCreationException : Exception
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо конструктор

}
this._expected = expected;
this._real = real;
this._ignoreDesc = ignoreDesc;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignoreDescription?

{
var methods = type.GetMethods();
var befores = methods.Where(method => method.GetCustomAttributes<Before>().Any());
var afters = methods.Where(method => method.GetCustomAttributes<Before>().Any());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var afters = methods.Where(method => method.GetCustomAttributes<Before>().Any());
var afters = methods.Where(method => method.GetCustomAttributes<After>().Any());

.Select(method =>
{
var testAttr = method.GetCustomAttributes<Test>().First();
befores.AsParallel().ForAll(before => before.Invoke(null, null));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не, before и after не статические методы, их надо вызывать на объекте класса

{
try
{
method.Invoke(method.DeclaringType, null);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Чтобы гонок между тестами не было, надо каждый тестовый метод запускать на своём отдельном объекте. И создавать эти объекты стоит после вызова BeforeClass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants