-
Notifications
You must be signed in to change notification settings - Fork 32
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
base: master
Are you sure you want to change the base?
Conversation
[TestCaseSource(typeof(ColorConverterTestData), nameof(ColorConverterTestData.RightCases))] | ||
public Color Converter_ShouldConvertStringToColor_WhenStringInRightFormat(string hexString) | ||
{ | ||
if (ColorConverter.TryConvert(hexString, out var color)) |
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.
Можно было проверить возвращаемый bool, а не кидать пустую ошибку
|
||
public class ColorConverterTestData | ||
{ | ||
public static IEnumerable<TestCaseData> RightCases |
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.
такие данные удобнее хранить в классе теста
} | ||
|
||
[Test] | ||
public void DrawOneTundredRectangles() |
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.
Опечатка
if (TagCloudServicesFactory.ConfigureServiceAndTryGet<TagCloudGenerator>(option, out var generator)) | ||
generator.Generate(); | ||
else | ||
throw new Exception("Can't configure service"); |
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.
Если введены неверные аргументы, лучше вывести об этом сообщение и завершить исполнение с не нулевым кодом, а не кидать Exception
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.
Результат генерации получился странным. Крупные слова разбросаны по всему облаку, а так быть не должно
|
||
private void SaveToFile(Bitmap bitmap) | ||
{ | ||
var pathToFile = @$"{path}\{name}"; |
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.
Сейчас это не так важно, потому, что код запуститься только на windows из-за зависимостей, но на будущее, для обьединения путей стоит использовать Path.Combine или хотя бы Path.PathSeparator
var rgbValue = hexString | ||
.Replace("#", "") | ||
.Chunk(2) | ||
.Select(chars => Convert.ToInt32(new string(chars), 16)) | ||
.ToArray(); |
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.
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")] |
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.
Попробуй посмотреть описание любой часто используемой консольной программы, сдеалнное тобой описание не информативно
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(); |
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.
эти условия можно заменить полиморфизмом
@@ -0,0 +1,7 @@ | |||
namespace TagCloud.TextHandlers; | |||
|
|||
public class TextData |
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.
Этот класс не стоило вводить, можно заменить его на ValueTuple
No description provided.