{"id":19620629,"url":"https://github.com/nakov/unittestingexample-collections","last_synced_at":"2026-05-13T01:05:10.661Z","repository":{"id":146213800,"uuid":"356247038","full_name":"nakov/UnitTestingExample-Collections","owner":"nakov","description":"Unit testing example with C# and NUnit","archived":false,"fork":false,"pushed_at":"2021-04-21T09:52:57.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-26T18:53:18.166Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nakov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-09T11:31:16.000Z","updated_at":"2021-07-13T17:37:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"f4fae7d0-dbe2-4903-8048-67105a94aeeb","html_url":"https://github.com/nakov/UnitTestingExample-Collections","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nakov/UnitTestingExample-Collections","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nakov%2FUnitTestingExample-Collections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nakov%2FUnitTestingExample-Collections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nakov%2FUnitTestingExample-Collections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nakov%2FUnitTestingExample-Collections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nakov","download_url":"https://codeload.github.com/nakov/UnitTestingExample-Collections/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nakov%2FUnitTestingExample-Collections/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32963180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T23:30:32.555Z","status":"ssl_error","status_checked_at":"2026-05-12T23:30:18.191Z","response_time":102,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T11:19:30.477Z","updated_at":"2026-05-13T01:05:10.641Z","avatar_url":"https://github.com/nakov.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unit Testing Example: Collection\u003cT\u003e, CircularQueue\u003cT\u003e\n\nUnit testing examples with **C#** and **NUnit**.\n\n## Class for Testing: Collection\\\u003cT\u003e\n\nWe are given a **C# class [`Collection\u003cT\u003e`](https://github.com/nakov/UnitTestingExample/blob/main/Collections/Collection.cs)**, implementing a generic collection, holding an indexed sequence of elements:\n\n```cs\npublic class Collection\u003cT\u003e\n{\n  public int Capacity { … }\n  public int Count { … }\n  public Collection(params T[] items) { … }\n  public void Add(T item) { … }\n  public void AddRange(params T[] items) { … }\n  public T this[int index] { … }\n  public void InsertAt(int index, T item) { … }\n  public void Exchange(int index1, int index2) { … }\n  public T RemoveAt(int index) { … }\n  public void Clear() { … }\n  public override string ToString() { … }\n}\n```\n\n## Unit Tests for the Collection\\\u003cT\u003e Class\n\nWrite **unit tests** to test the functionality of the [`Collection\u003cT\u003e`](https://github.com/nakov/UnitTestingExample/blob/main/Collections/Collection.cs) class, with high code coverage.\n\n_Hint_: You may implement the following tests:\n\n```cs\npublic class CollectionTests\n{\n  public void Test_Collection_EmptyConstructor() { … }\n  public void Test_Collection_ConstructorSingleItem() { … }\n  public void Test_Collection_ConstructorMultipleItems() { … }\n  public void Test_Collection_Add() { … }\n  public void Test_Collection_AddWithGrow() { … }\n  public void Test_Collection_AddRange() { … }\n  public void Test_Collection_GetByIndex() { … }\n  public void Test_Collection_GetByInvalidIndex() { … }\n  public void Test_Collection_SetByIndex() { … }\n  public void Test_Collection_SetByInvalidIndex() { … }\n  public void Test_Collection_AddRangeWithGrow() { … }\n  public void Test_Collection_InsertAtStart() { … }\n  public void Test_Collection_InsertAtEnd() { … }\n  public void Test_Collection_InsertAtMiddle() { … }\n  public void Test_Collection_InsertAtWithGrow() { … }\n  public void Test_Collection_InsertAtInvalidIndex() { … }\n  public void Test_Collection_ExchangeMiddle() { … }\n  public void Test_Collection_ExchangeFirstLast() { … }\n  public void Test_Collection_ExchangeInvalidIndexes() { … }\n  public void Test_Collection_RemoveAtStart() { … }\n  public void Test_Collection_RemoveAtEnd() { … }\n  public void Test_Collection_RemoveAtMiddle() { … }\n  public void Test_Collection_RemoveAtInvalidIndex() { … }\n  public void Test_Collection_RemoveAll() { … }\n  public void Test_Collection_Clear() { … }\n  public void Test_Collection_CountAndCapacity() { … }\n  public void Test_Collection_ToStringEmpty() { … }\n  public void Test_Collection_ToStringSingle() { … }\n  public void Test_Collection_ToStringMultiple() { … }\n  public void Test_Collection_ToStringCollectionOfCollections() { … }\n  public void Test_Collection_1MillionItems() { … }\n}\n```\n\n## Expected Results\n\nSample output from the **unit tests**:\n\n![image](https://user-images.githubusercontent.com/1689586/114179602-e0500380-9947-11eb-8cb2-737823fe5f62.png)\n\nSample output from the **code coverage**:\n\n![image](https://user-images.githubusercontent.com/1689586/114179830-2a38e980-9948-11eb-8e4d-a21069de0088.png)\n\n\n## Class for Testing: CircularQueue\\\u003cT\u003e\n\nWe are given a **C# class [`CircularQueue\u003cT\u003e`](https://github.com/nakov/UnitTestingExample/blob/main/Collections/CircularQueue.cs)**, implementing the \"**queue**\" data structure, using a **circular buffer**:\n\n```cs\npublic class CircularQueue\u003cT\u003e\n{\n    public CircularQueue(int capacity) { … }\n    public int Count { … }\n    public void Enqueue(T element) { … }\n    public T Dequeue() { … }\n    public T Peek() { … }\n    public T[] ToArray() { … }\n    public override string ToString() { … }\n}\n```\n\n## Unit Tests for the CircularQueue\\\u003cT\u003e Class\n\nWrite **unit tests** to test the functionality of the [`CircularQueue\u003cT\u003e`](https://github.com/nakov/UnitTestingExample/blob/main/Collections/CircularQueue.cs) class, with high code coverage.\n\n_Hint_: You may implement the following tests:\n\n```cs\nclass CircularQueueTests\n{\n    public void Test_CircularQueue_ConstructorDefault() { … }\n    public void Test_CircularQueue_ConstructorWithCapacity() { … }\n    public void Test_CircularQueue_Enqueue() { … }\n    public void Test_CircularQueue_EnqueueWithGrow() { … }\n    public void Test_CircularQueue_Dequeue() { … }\n    public void Test_CircularQueue_DequeueEmpty() { … }\n    public void Test_CircularQueue_EnqueueDequeue_WithRangeCross() { … }\n    public void Test_CircularQueue_Peek() { … }\n    public void Test_CircularQueue_PeekEmpty() { … }\n    public void Test_CircularQueue_ToArray() { … }\n    public void Test_CircularQueue_ToArray_WithRangeCross() { … }\n    public void Test_CircularQueue_ToString() { … }\n    public void Test_CircularQueue_MultipleOperations() { … }\n    public void Test_CircularQueue_1MillionItems() { … }\n}\n```\n\n## Expected Results\n\nSample output from the **unit tests**:\n\n![image](https://user-images.githubusercontent.com/1689586/115532136-30ab5780-a29e-11eb-88ab-338cdcfd9a22.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnakov%2Funittestingexample-collections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnakov%2Funittestingexample-collections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnakov%2Funittestingexample-collections/lists"}