Conversation
Идея хорошая, что с реализацией? |
Это бред, по воспоминаниям я писал коммент, когда и доделал задачу(это подразумевает пуш), но я не запушил, извиняюсь |
C#/forSpbu/MyNUnit/Attributes.cs
Outdated
| /// Test method attribute | ||
| /// </summary> | ||
| [AttributeUsage(AttributeTargets.Method)] | ||
| public class Test : Attribute |
There was a problem hiding this comment.
Один файл -- один класс. И название каждого атрибута должно словом Attribute заканчиваться. Например, BeforeAttribute
| [AttributeUsage(AttributeTargets.Method)] | ||
| public class Test : Attribute | ||
| { | ||
| /// <summary> |
C#/forSpbu/MyNUnit/Program.cs
Outdated
| Console.WriteLine("Incorrect argument, should be project assembly(binary or dll) path"); | ||
| } | ||
|
|
||
| var assembly = Assembly.LoadFile(args[0]); |
There was a problem hiding this comment.
Не, в условии же по переданному пути может находиться несколько сборок
| /// <summary> | ||
| /// Successful run result implementation | ||
| /// </summary> | ||
| public class OkResult : RunResult |
There was a problem hiding this comment.
Тут в классах Result компилятор ругается на то, что не переопределяется метод Equals
| namespace MyNUnit; | ||
|
|
||
| public class TestResultCreationException : Exception | ||
| { |
C#/forSpbu/MyNUnit/TestResult.cs
Outdated
| } | ||
| this._expected = expected; | ||
| this._real = real; | ||
| this._ignoreDesc = ignoreDesc; |
C#/forSpbu/MyNUnit/Tester.cs
Outdated
| { | ||
| var methods = type.GetMethods(); | ||
| var befores = methods.Where(method => method.GetCustomAttributes<Before>().Any()); | ||
| var afters = methods.Where(method => method.GetCustomAttributes<Before>().Any()); |
There was a problem hiding this comment.
| var afters = methods.Where(method => method.GetCustomAttributes<Before>().Any()); | |
| var afters = methods.Where(method => method.GetCustomAttributes<After>().Any()); |
C#/forSpbu/MyNUnit/Tester.cs
Outdated
| .Select(method => | ||
| { | ||
| var testAttr = method.GetCustomAttributes<Test>().First(); | ||
| befores.AsParallel().ForAll(before => before.Invoke(null, null)); |
There was a problem hiding this comment.
Не, before и after не статические методы, их надо вызывать на объекте класса
C#/forSpbu/MyNUnit/Tester.cs
Outdated
| { | ||
| try | ||
| { | ||
| method.Invoke(method.DeclaringType, null); |
There was a problem hiding this comment.
Чтобы гонок между тестами не было, надо каждый тестовый метод запускать на своём отдельном объекте. И создавать эти объекты стоит после вызова BeforeClass
От одногрупника поступило предложение потренить функциональное мышление используя linq по возможности, так что тут я поставил челендж написать все без единого цикла