Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Калентьев Илья tg: @m1nus0ne #22

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

Conversation

m1nus0ne
Copy link

No description provided.

[TestCaseSource(typeof(ColorConverterTestData), nameof(ColorConverterTestData.RightCases))]
public Color Converter_ShouldConvertStringToColor_WhenStringInRightFormat(string hexString)
{
if (ColorConverter.TryConvert(hexString, out var color))
Copy link

Choose a reason for hiding this comment

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

Можно было проверить возвращаемый bool, а не кидать пустую ошибку


public class ColorConverterTestData
{
public static IEnumerable<TestCaseData> RightCases
Copy link

Choose a reason for hiding this comment

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

такие данные удобнее хранить в классе теста

}

[Test]
public void DrawOneTundredRectangles()
Copy link

Choose a reason for hiding this comment

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

Опечатка

if (TagCloudServicesFactory.ConfigureServiceAndTryGet<TagCloudGenerator>(option, out var generator))
generator.Generate();
else
throw new Exception("Can't configure service");
Copy link

Choose a reason for hiding this comment

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

Если введены неверные аргументы, лучше вывести об этом сообщение и завершить исполнение с не нулевым кодом, а не кидать Exception

Copy link

Choose a reason for hiding this comment

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

Результат генерации получился странным. Крупные слова разбросаны по всему облаку, а так быть не должно


private void SaveToFile(Bitmap bitmap)
{
var pathToFile = @$"{path}\{name}";
Copy link

Choose a reason for hiding this comment

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

Сейчас это не так важно, потому, что код запуститься только на windows из-за зависимостей, но на будущее, для обьединения путей стоит использовать Path.Combine или хотя бы Path.PathSeparator

Comment on lines +14 to +18
var rgbValue = hexString
.Replace("#", "")
.Chunk(2)
.Select(chars => Convert.ToInt32(new string(chars), 16))
.ToArray();
Copy link

Choose a reason for hiding this comment

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

rgb коды могут задаваться 3 hex цифрами

[Option('d', "destination", HelpText = "Set destination path.", Default = @"..\..\..\Results")]
public string DestinationPath { get; set; }

[Option('s', "source", HelpText = "Set source path.", Default = @"..\..\..\Results\text.txt")]
Copy link

Choose a reason for hiding this comment

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

Попробуй посмотреть описание любой часто используемой консольной программы, сдеалнное тобой описание не информативно

Comment on lines +34 to +41
if (options.ColorScheme == "gray")
builder.RegisterType<RandomColorSelector>().As<IColorSelector>().SingleInstance();
if (options.ColorScheme == "random")
builder.RegisterType<GrayScaleColorSelector>().As<IColorSelector>().SingleInstance();
else if (ColorConverter.TryConvert(options.ColorScheme, out var color))
builder.Register(provider => new ConstantColorSelector(color)).As<IColorSelector>().SingleInstance();
else
builder.Register(provider => new ConstantColorSelector(Color.Black)).As<IColorSelector>().SingleInstance();
Copy link

Choose a reason for hiding this comment

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

эти условия можно заменить полиморфизмом

@@ -0,0 +1,7 @@
namespace TagCloud.TextHandlers;

public class TextData
Copy link

Choose a reason for hiding this comment

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

Этот класс не стоило вводить, можно заменить его на ValueTuple

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