-
Notifications
You must be signed in to change notification settings - Fork 2
Guard #19
base: master
Are you sure you want to change the base?
Guard #19
Conversation
@@ -35,6 +37,7 @@ public GraphLabsContextImpl(GraphLabsContext ctx) | |||
private Type GetEntityTypeFor(Type type) | |||
{ | |||
Contract.Assert(typeof(AbstractEntity).IsAssignableFrom(type)); | |||
Guard.Guard.AreAssignedTypes(typeof(AbstractEntity), type); //* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нужно зайти в настройки проекта Guard, и там поменять deafult namecpacе: вместо GraphLabs.Guard написать GraphLabs. После чего поменять пространство имён для класса Guard аналогичным образом.
@@ -18,6 +18,7 @@ public class ChangesTracker : IChangesTracker | |||
public ChangesTracker(GraphLabsContext context) | |||
{ | |||
Contract.Requires(context != null); | |||
Guard.Guard.IsNotNull(context, nameof(context) ); //* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//* надо удалить =)
|
||
get | ||
{ | ||
Guard.Guard.IsNotNull(_originalValues.Value, nameof(_originalValues.Value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут вернуть как было, значение реально может быть null и это ок
get { return _currentValues.Value; } | ||
get | ||
{ | ||
Guard.Guard.IsNotNull(_currentValues.Value, nameof(_currentValues.Value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
здесь тоже
@@ -28,59 +29,66 @@ public RepositoryFactory(GraphLabsContext context, ISystemDateService systemDate | |||
public IGroupRepository GetGroupRepository() | |||
{ | |||
Contract.Ensures(Contract.Result<IGroupRepository>() != null); | |||
|
|||
return new GroupRepository(_context); | |||
GroupRepository groupRepository = new GroupRepository(_context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@использовать var вмеcто GroupRepository
} | ||
|
||
/// <summary> Получить репозиторий с группами </summary> | ||
[NotNull] | ||
public ISessionRepository GetSessionRepository() | ||
{ | ||
Contract.Ensures(Contract.Result<ISessionRepository>() != null); | ||
|
||
return new SessionRepository(_context, _systemDateService); | ||
SessionRepository sessionRepository = new SessionRepository(_context, _systemDateService); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var
} | ||
|
||
/// <summary> Получить репозиторий с лабораторными работами </summary> | ||
[NotNull] | ||
public ILabRepository GetLabRepository() | ||
{ | ||
Contract.Ensures(Contract.Result<ILabRepository>() != null); | ||
|
||
return new LabRepository(_context, _tasksContext); | ||
LabRepository labRepository = new LabRepository(_context, _tasksContext); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var
<package id="xunit.abstractions" version="2.0.1" targetFramework="net452" /> | ||
<package id="xunit.JetBrains" version="1.9.2" targetFramework="net452" /> | ||
<package id="xunit.runner.utility" version="2.3.1" targetFramework="net452" /> | ||
<package id="YamlDotNet.Signed" version="4.2.1" targetFramework="net452" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
здесь явно слишком много зависимостей. должны быть только R#-аннотации
Contract.Ensures( | ||
Contract.Result<LoginResult>() != LoginResult.Success & Contract.ValueAtReturn(out sessionGuid) == Guid.Empty || | ||
Contract.Result<LoginResult>() == LoginResult.Success & Contract.ValueAtReturn(out sessionGuid) != Guid.Empty); | ||
Guard.Guard.IsTrueAssertion(default(LoginResult) != LoginResult.Success & sessionGuid == Guid.Empty || | ||
default(LoginResult) == LoginResult.Success & sessionGuid != Guid.Empty); | ||
|
||
return default(LoginResult); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
этот файл вообще должен удалиться.
Guard.Guard.IsTrueAssertion(IpHelper.CheckIsValidIP(clientIp)); | ||
Guard.Guard.IsTrueAssertion(TryLoginImpl(email, password, clientIp, ref sessionGuid, force: false) != LoginResult.Success & sessionGuid == Guid.Empty || | ||
TryLoginImpl(email, password, clientIp, ref sessionGuid, force: false) == LoginResult.Success & sessionGuid != Guid.Empty); | ||
return TryLoginImpl(email, password, clientIp, ref sessionGuid, force: false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
надо var result = TryLoginImpl(...)
а потом все проверки
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Проверка всех условий через Guard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard
No description provided.