International Calling Connoisseur - Tests should check for correct handling of duplicate Add().

Open
#1,845 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp

Research direction

Locate the tests for DialingCodes.AddCountryToExistingDictionary and review the Intro-to-Dictionaries text. Add coverage for duplicate-key handling using the existing dictionary and verify that the test suite rejects implementations that call Add() without checking the key first.

Written by the indexing model from the issue text.

Description

Add() throws if the key is already in the dictionary. I saw a bunch of passing solutions that don't check for the key before calling Add().

In general, there's lots of ways for dictionaries to throw exceptions when you do naive-but-seemingly-reasonable things, and the "Intro-to-Dictionaries" text might want to call out the common ways to go wrong.

Example test:

var countryCodes = DialingCodes.AddCountryToExistingDictionary(DialingCodes.GetExistingDictionary(), 91, "India");
Assert.Equal("India", countryCodes[91]);

Dominant language
C#
Stars
428
Forks
384
Avg merge
2d 2h
Merged PRs (30d)
5

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from exercism/csharp

All issues in exercism/csharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.