< Summary

Information
Class: Utility.Components.Regex.RegexFromString
Assembly: Utility
File(s): /home/runner/work/Utility-Blazor/Utility-Blazor/src/Utility/Components/Regex/RegexFromString.razor
Tag: 254_14892742572
Line coverage
0%
Covered lines: 0
Uncovered lines: 19
Coverable lines: 19
Total lines: 85
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Output()100%210%
OnInitialized()100%210%
Generate()0%620%
Copy()100%210%

File(s)

/home/runner/work/Utility-Blazor/Utility-Blazor/src/Utility/Components/Regex/RegexFromString.razor

#LineLine coverage
 1@using System.Text
 2@using Fare
 3@inject IJSRuntime JSRuntime
 4
 5<div class="container">
 6    <div class="row">
 7        <div class="col">
 8
 9            <label class="label-control">Regular Expression:</label>
 10            <div class="input-group">
 11                <input type="regularExpression" id="regularExpression" name="regularExpression" class="form-control" @bi
 12            </div>
 13
 14        </div>
 15
 16        <div class="col">
 17
 18            <label class="label-control">Count:</label>
 19            <div class="input-group">
 20                <input type="count" id="count" name="count" class="form-control" @bind="Count">
 21            </div>
 22
 23        </div>
 24
 25    </div>
 26
 27    <div class="row">
 28        <div class="col">
 29            <button id="Generate" name="Generate" @onclick="Generate" class="btn btn-success float-right">Generate</butt
 30        </div>
 31    </div>
 32
 33    <div class="row">
 34        <div class="col">
 35            <div class="input-group">
 36                <textarea id="output" class="form-control" rows="@Count" @bind="Output"></textarea>
 37                <span class="input-group-btn">
 38                    <button id="btnCopy" name="btnCopy" class="btn btn-info float-right" @onclick="Copy"><i class="far f
 39                </span>
 40            </div>
 41        </div>
 42    </div>
 43
 44    <div class="row">
 45        <div class="col">
 46            <p>Inspired from <a href="https://onlinestringtools.com/generate-string-from-regex" target="_blank">String f
 47        </div>
 48    </div>
 49
 50</div>
 51
 52@code
 53{
 54    [Parameter]
 055    public string Output { get; set; }
 56
 57    string RegularExpression;
 58    int Count;
 59
 60    protected override void OnInitialized()
 061    {
 062        RegularExpression = @"\d{1,5}";
 063        Count = 5;
 064        Output = "";
 065    }
 66
 67    private void Generate()
 068    {
 069        StringBuilder builder = new StringBuilder();
 070        for (int i = 0; i < Count; i++)
 071        {
 072            var xeger = new Xeger(RegularExpression);
 073            var random = xeger.Generate();
 74
 075            builder.Append(random + System.Environment.NewLine);
 076        }
 77
 078        Output = builder.ToString().Trim();
 079    }
 80
 81    async Task Copy()
 082    {
 083        await JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", Output);
 084    }
 85}