Skip to content
This repository was archived by the owner on Jun 7, 2020. It is now read-only.

Guard #19

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Guard #19

wants to merge 6 commits into from

Conversation

vinogradovaanna
Copy link

No description provided.

@@ -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); //*
Copy link
Member

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) ); //*
Copy link
Member

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));
Copy link
Member

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));
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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" />
Copy link
Member

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);
}
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

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

надо var result = TryLoginImpl(...)
а потом все проверки

Copy link
Author

@vinogradovaanna vinogradovaanna left a comment

Choose a reason for hiding this comment

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

Проверка всех условий через Guard

Copy link
Author

@vinogradovaanna vinogradovaanna left a comment

Choose a reason for hiding this comment

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

Guard

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants