Can't reproduce test failures in Diamond Exercise

Hi,

I’m struggling to get my program to pass the tests but I can’t reproduce the failures exercism is flagging in my own IDE.

I’ve passed it into chatGPT put it only suggests style changes, can anybody give any insights?

Thanks in advance.

using System;
using System.Text;

public static class Diamond
{
 public static string Make(char target)
 {
     if (target < 'A' || target > 'Z')
         throw new ArgumentOutOfRangeException(nameof(target), "Target must be between 'A' and 'Z'.");

     var sb = new StringBuilder();
     int size = target - 'A';
     
     for (int i = 0; i <= size; i++)
     {
         sb.AppendLine(DrawLine(size - i, (char)('A' + i), i));
     }
     
     for (int i = size - 1; i >= 0; i--)
     {
         sb.AppendLine(DrawLine(size - i, (char)('A' + i), i));
     }

     return sb.ToString();
 }

 private static string DrawLine(int padding, char letter, int innerSpace)
 {
     var sb = new StringBuilder();

     sb.Append(new string('·', padding));
     sb.Append(letter);
     
     if (innerSpace > 0)
     {
         sb.Append(new string('·', innerSpace * 2 - 1));
         sb.Append(letter);
     }

     sb.Append(new string('·', padding));
     
     return sb.ToString();
 }
}

What are the errors you’re seeing online?

Are you running the unit tests in your IDE?

Hi @glennj, I’m getting the following:

var actual = Diamond.Make(letter);
var rows = Rows(actual);
var firstRowCharacters = rows.First().Trim();
Assert.Equal("A", firstRowCharacters);

Test Failure

Falsifiable, after 1 test (0 shrinks) (StdGen (581455322,297367746)): Original: ‘X’

Hi @IsaacG, no I’m not running the unit tests, here’s a fiddle though:

And I’ve since noticed that when I run it through the alphabet like that, I am getting some unusual special chars, any idea where they might be coming from?

Using the unit tests is the best way to test your code locally ;) It would give you the same results locally as you’d get on the website and should be fairly easy to do. See Testing on the C# track | Exercism's Docs