Skip to content

Conversation

@Hellothereyoko
Copy link

Its just me doing this assignment. I've tried my best to complete this to the requirements to have SOMETHING for peer review. I know my unit tests are light, but im open to figuring out where I could enhance them...

Copy link

@RyanHirte RyanHirte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement the ISampleData.CsvRows property, loading the data from the People.csv file and returning each line as a single string. ✔

Change the "Copy to" property on People.csv to "Copy if newer" so that the file is deployed along with your test project. ❌
Using LINQ, skip the first row in the People.csv. ✔
Be sure to appropriately handle resource (IDisposable) items correctly if applicable (and it may not be depending on how you implement it). ✔
Implement IEnumerable GetUniqueSortedListOfStatesGivenCsvRows() to return a sorted, unique list of states. ✔

Use ISampleData.CsvRows for your data source. ✔
Don't forget the list should be unique. ✔
Sort the list alphabetically. ✔
Include a test that leverages a hardcoded list of addresses. ✔
Include a test that uses LINQ to verify the data is sorted correctly (do not use a hardcoded list). ✔
Implement ISampleData.GetAggregateSortedListOfStatesUsingCsvRows() to return a string that contains a unique, comma separated list of states. ✔

Use ISampleData.GetUniqueSortedListOfStatesGivenCsvRows() for your data source. ✔
Consider "selecting" only the states and calling ToArray() to retrieve an array of all the state names. ✔
Given the array, consider using string.Join to combine the list into a single string. ✔
Implement the ISampleData.People property to return all the items in People.csv as Person objects ✔

Use ISampleData.CsvRows as the source of the data. ✔
Sort the list by State, City, and Zip. ✔
Be sure that Person.Address is also populated. ✔
Adding null validation to all the Person and Address properties is optional.
Consider using ISampleData.CsvRows in your test to verify your results. ✔
Implement ISampleDate.FilterByEmailAddress(Predicate filter) to return a list of names where the email address matches the filter. ✔

Use ISampleData.People for your data source. ✔
Implement ISampleData.GetAggregateListOfStatesGivenPeopleCollection(IEnumerable people) to return a string that contains a unique, comma-separated list of states. ✔

Use the people parameter from ISampleData.People property for your data source. ✔
At a minimum, use the System.Linq.Enumerable.Aggregate` LINQ method to create your result. ✔
Don't forget the list should be unique. ✔
It is recommended that, at a minimum, you use ISampleData.GetUniqueSortedListOfStatesGivenCsvRows to validate your result.
Given the implementation of Node in Assignment5

Implement IEnumerable to return all the items in the "circle" of items. ✔
Add an IEnumberable ChildItems(int maximum) method to Node that returns the remaining items with a maximum number of items returned less than maximum.
Extra Credit
Implement the homework using async/await and multi-threading by defining a new SampleDataAsync class that implements IAsyncSampleData). Refactor your SampleData and SampleDataAsync classes with minimal duplication. Be sure to refactor your tests to re-use a significant amount of the test code for both implementations. ✔
Fundamentals
Place all shared project properties into a Directory.Build.Props file.
Place all shared project items into a Directory.Build.targets file.
Ensure nullable reference types is enabled ✔
Ensure that you turn on code analysis for all projects(EnableNETAnalyzers) ✔
Set LangVersion and the TargetFramework to the latest released versions available (preview versions optional) ❌
and enabled .NET analyzers for both projects ✔
For this assignment, consider using Assert.AreEqual() (the generic version) ❌
All of the above should be unit tested ✔
Choose simplicity over complexity ✔

Good extra credit attempt, you are already aware but just missing some testing I think, Also you could have done this and it wasn't source controlled, but:

Change the "Copy to" property on People.csv to "Copy if newer" so that the file is deployed along with your test project. ❌

This wasn't changed when I pulled your branch to my computer, but once again don't know if this gets source controlled.

Great job!

@@ -0,0 +1,39 @@
using Assignment;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you put this in a separate file, but I think it would also be good to include some unit tests for this separately as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. Is there a certain example you think would fit this in terms of unit testing?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think including a test verifying it parses into a person object correctly. I know this is used in your SampleData stuff so this is tested anyways when you unit test that file, but I think it could potentially help with issues where you aren't sure from your SampleDataTests whether it's an issue with the actual methods or parsing the file. Basically I think it could help bug hunt.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that sounds like it would be SUPER helpful. Should I chuck it into my SampleDataTests or make it into it's own test harness?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be easier/cleaner to make it's own test file.

Copy link

@thigiang16 thigiang16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement the ISampleData.CsvRows property, loading the data from the People.csv file and returning each line as a single string. ✔

Change the "Copy to" property on People.csv to "Copy if newer" so that the file is deployed along with your test project. ❌
Using LINQ, skip the first row in the People.csv. ✔
Be sure to appropriately handle resource (IDisposable) items correctly if applicable (and it may not be depending on how you implement it). ✔
Implement IEnumerable GetUniqueSortedListOfStatesGivenCsvRows() to return a sorted, unique list of states. ✔

Use ISampleData.CsvRows for your data source. ✔
Don't forget the list should be unique. ✔
Sort the list alphabetically. ✔
Include a test that leverages a hardcoded list of addresses. ✔
Include a test that uses LINQ to verify the data is sorted correctly (do not use a hardcoded list). ✔
Implement ISampleData.GetAggregateSortedListOfStatesUsingCsvRows() to return a string that contains a unique, comma separated list of states. ✔

Use ISampleData.GetUniqueSortedListOfStatesGivenCsvRows() for your data source. ✔
Consider "selecting" only the states and calling ToArray() to retrieve an array of all the state names. ✔
Given the array, consider using string.Join to combine the list into a single string. ✔
Implement the ISampleData.People property to return all the items in People.csv as Person objects ✔

Use ISampleData.CsvRows as the source of the data. ✔
Sort the list by State, City, and Zip. ✔
Be sure that Person.Address is also populated. ✔
Adding null validation to all the Person and Address properties is optional.
Consider using ISampleData.CsvRows in your test to verify your results. ✔
Implement ISampleDate.FilterByEmailAddress(Predicate filter) to return a list of names where the email address matches the filter. ✔

Use ISampleData.People for your data source. ✔
Implement ISampleData.GetAggregateListOfStatesGivenPeopleCollection(IEnumerable people) to return a string that contains a unique, comma-separated list of states. ✔

Use the people parameter from ISampleData.People property for your data source. ✔
At a minimum, use the System.Linq.Enumerable.Aggregate` LINQ method to create your result. ✔
Don't forget the list should be unique. ✔
It is recommended that, at a minimum, you use ISampleData.GetUniqueSortedListOfStatesGivenCsvRows to validate your result.
Given the implementation of Node in Assignment5

Implement IEnumerable to return all the items in the "circle" of items. ✔
Add an IEnumberable ChildItems(int maximum) method to Node that returns the remaining items with a maximum number of items returned less than maximum.
Extra Credit
Implement the homework using async/await and multi-threading by defining a new SampleDataAsync class that implements IAsyncSampleData). Refactor your SampleData and SampleDataAsync classes with minimal duplication. Be sure to refactor your tests to re-use a significant amount of the test code for both implementations. ✔
Fundamentals
Place all shared project properties into a Directory.Build.Props file.
Place all shared project items into a Directory.Build.targets file.
Ensure nullable reference types is enabled ✔
Ensure that you turn on code analysis for all projects(EnableNETAnalyzers) ✔
Set LangVersion and the TargetFramework to the latest released versions available (preview versions optional) ❌
and enabled .NET analyzers for both projects ✔
For this assignment, consider using Assert.AreEqual() (the generic version) ❌
All of the above should be unit tested ❌
Choose simplicity over complexity ✔

Nice work! I think you could add more tests for SampleData and Node. It might be helpful to create a separate NodeTests class for easier tracking. Also, there’s no test file for SampleDataAsyncTests. Adding one would help cover all your async implementations.

public IEnumerator<T> GetEnumerator()
{
yield return Data;
var current = Next;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used a slightly different way by starting with current = this and using a do-while loop, which ensures we yield the first node before checking the loop condition. But I see your approach works well!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to use more processing time than needed. So, I thought it might be smarter to keep it simple. Is there a particular reason you used a certain approach. I'd like to kinda see how you did it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t think of other approaches until I saw yours. Here’s my version if you want to take a look

public IEnumerator<T> GetEnumerator()
    {
        Node<T> current = this;
        do
        {
            yield return current.Value;
            current = current.Next;
        }
        while (current != this);
    }
    IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();


// Returns remaining items with max count
public IEnumerable<T> ChildItems(int maximum)
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add ArgumentOutOfRangeException.ThrowIfNegative(maximum) to validate the input.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you show me where you would put it? Did you put it in the method declaration or did you just throw it when that condition naturally came up?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put it at the start of the method, so it validates the input before doing any processing.


Assert.AreEqual("OR, WA", result);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add more test cases to ensure GetUniqueSortedListOfStatesGivenCsvRows and GetAggregateSortedListOfStatesUsingCsvRows correctly handle duplicate states, and that FilterByEmailAddress works when there are no matching emails


public string GetAggregateSortedListOfStatesUsingCsvRows()
{
var states = GetUniqueSortedListOfStatesGivenCsvRows().ToEnumerable().ToList();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of ToEnumerable().ToList(), consider using await foreach to build the list asynchronously to keep it fully async

Comment on lines +60 to +61
.Select(CsvParser.ParsePersonFromCsvRow)
.OrderBy(p => p.Address.State)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this chain is synchronous. You could consider using await foreach or async-compatible LINQ patterns if you want fully asynchronous behavior. Correct me if I'm wrong, I'm still learning this! :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if it was explicitly required. I'll look into it to see if I can improve it. But I have a feeling you may be onto something. 😎

@Hellothereyoko
Copy link
Author

Implement the ISampleData.CsvRows property, loading the data from the People.csv file and returning each line as a single string. ✔

Change the "Copy to" property on People.csv to "Copy if newer" so that the file is deployed along with your test project. ❌ Using LINQ, skip the first row in the People.csv. ✔ Be sure to appropriately handle resource (IDisposable) items correctly if applicable (and it may not be depending on how you implement it). ✔ Implement IEnumerable GetUniqueSortedListOfStatesGivenCsvRows() to return a sorted, unique list of states. ✔

Use ISampleData.CsvRows for your data source. ✔ Don't forget the list should be unique. ✔ Sort the list alphabetically. ✔ Include a test that leverages a hardcoded list of addresses. ✔ Include a test that uses LINQ to verify the data is sorted correctly (do not use a hardcoded list). ✔ Implement ISampleData.GetAggregateSortedListOfStatesUsingCsvRows() to return a string that contains a unique, comma separated list of states. ✔

Use ISampleData.GetUniqueSortedListOfStatesGivenCsvRows() for your data source. ✔ Consider "selecting" only the states and calling ToArray() to retrieve an array of all the state names. ✔ Given the array, consider using string.Join to combine the list into a single string. ✔ Implement the ISampleData.People property to return all the items in People.csv as Person objects ✔

Use ISampleData.CsvRows as the source of the data. ✔ Sort the list by State, City, and Zip. ✔ Be sure that Person.Address is also populated. ✔ Adding null validation to all the Person and Address properties is optional. Consider using ISampleData.CsvRows in your test to verify your results. ✔ Implement ISampleDate.FilterByEmailAddress(Predicate filter) to return a list of names where the email address matches the filter. ✔

Use ISampleData.People for your data source. ✔ Implement ISampleData.GetAggregateListOfStatesGivenPeopleCollection(IEnumerable people) to return a string that contains a unique, comma-separated list of states. ✔

Use the people parameter from ISampleData.People property for your data source. ✔ At a minimum, use the System.Linq.Enumerable.Aggregate` LINQ method to create your result. ✔ Don't forget the list should be unique. ✔ It is recommended that, at a minimum, you use ISampleData.GetUniqueSortedListOfStatesGivenCsvRows to validate your result. Given the implementation of Node in Assignment5

Implement IEnumerable to return all the items in the "circle" of items. ✔ Add an IEnumberable ChildItems(int maximum) method to Node that returns the remaining items with a maximum number of items returned less than maximum. Extra Credit Implement the homework using async/await and multi-threading by defining a new SampleDataAsync class that implements IAsyncSampleData). Refactor your SampleData and SampleDataAsync classes with minimal duplication. Be sure to refactor your tests to re-use a significant amount of the test code for both implementations. ✔ Fundamentals Place all shared project properties into a Directory.Build.Props file. Place all shared project items into a Directory.Build.targets file. Ensure nullable reference types is enabled ✔ Ensure that you turn on code analysis for all projects(EnableNETAnalyzers) ✔ Set LangVersion and the TargetFramework to the latest released versions available (preview versions optional) ❌ and enabled .NET analyzers for both projects ✔ For this assignment, consider using Assert.AreEqual() (the generic version) ❌ All of the above should be unit tested ✔ Choose simplicity over complexity ✔

Good extra credit attempt, you are already aware but just missing some testing I think, Also you could have done this and it wasn't source controlled, but:

Change the "Copy to" property on People.csv to "Copy if newer" so that the file is deployed along with your test project. ❌

This wasn't changed when I pulled your branch to my computer, but once again don't know if this gets source controlled.

Great job!

Hey Ryan, my repo is source controlled and I push changes in batches. I have queued up the changes to post in my upcoming pushes. Thanks for the feedback! I'll review the suggestions and will implement them accordingly... :)

@Hellothereyoko Hellothereyoko changed the title Assignment7+8: Rough Draft Assignment7+8: Revised Edits Nov 21, 2025
@github-actions
Copy link

Summary

Summary
Generated on: 11/21/2025 - 05:20:10
Coverage date: 11/21/2025 - 05:20:08
Parser: MultiReport (2x Cobertura)
Assemblies: 1
Classes: 6
Files: 6
Line coverage: 99.3% (153 of 154)
Covered lines: 153
Uncovered lines: 1
Coverable lines: 154
Total lines: 276
Branch coverage: 85.2% (58 of 68)
Covered branches: 58
Total branches: 68
Method coverage: Feature is only available for sponsors
Tag: 485_19560838182

Coverage

Assignment - 99.3%
Name Line Branch
Assignment 99.3% 85.2%
Assignment.Address 100%
Assignment.CsvParser 100% 93.7%
Assignment.Node`1 96.2% 100%
Assignment.Person 100%
Assignment.SampleData 100% 50%
Assignment.SampleDataAsync 100% 80%

Copy link
Collaborator

@Joshua-Lester3 Joshua-Lester3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instructions

Throughout, consider using the System.Linq.Enumerable methods Zip, Count, Sort and Contains methods for testing collections.. (Preferably avoid using Microsoft.VisualStudio.TestTools.UnitTesting.CollectionAssert although that might be easier, to get a firmer grasp on additional LINQ API.)

  1. Implement the ISampleData.CsvRows property, loading the data from the People.csv file and returning each line as a single string. ✔

    • Change the "Copy to" property on People.csv to "Copy if newer" so that the file is deployed along with your test project. ✔
    • Using LINQ, skip the first row in the People.csv. ✔
    • Be sure to appropriately handle resource (IDisposable) items correctly if applicable (and it may not be depending on how you implement it). ✔
  2. Implement IEnumerable<string> GetUniqueSortedListOfStatesGivenCsvRows() to return a sorted, unique list of states. ✔

    • Use ISampleData.CsvRows for your data source. ✔
    • Don't forget the list should be unique. ✔
    • Sort the list alphabetically. ✔
    • Include a test that leverages a hardcoded list of addresses. ✔
    • Include a test that uses LINQ to verify the data is sorted correctly (do not use a hardcoded list). ✔
  3. Implement ISampleData.GetAggregateSortedListOfStatesUsingCsvRows() to return a string that contains a unique, comma separated list of states. ✔

    • Use ISampleData.GetUniqueSortedListOfStatesGivenCsvRows() for your data source. ✔
    • Consider "selecting" only the states and calling ToArray() to retrieve an array of all the state names. ✔
    • Given the array, consider using string.Join to combine the list into a single string. ✔
  4. Implement the ISampleData.People property to return all the items in People.csv as Person objects ✔

    • Use ISampleData.CsvRows as the source of the data. ✔
    • Sort the list by State, City, and Zip. ✔
    • Be sure that Person.Address is also populated. ✔
    • Adding null validation to all the Person and Address properties is optional.
    • Consider using ISampleData.CsvRows in your test to verify your results. ✔
  5. Implement ISampleDate.FilterByEmailAddress(Predicate<string> filter) to return a list of names where the email address matches the filter. ✔

    • Use ISampleData.People for your data source. ✔
  6. Implement ISampleData.GetAggregateListOfStatesGivenPeopleCollection(IEnumerable<IPerson> people) to return a string that contains a unique, comma-separated list of states. ✔

    • Use the people parameter from ISampleData.People property for your data source. ✔
    • At a minimum, use the System.Linq.Enumerable.Aggregate` LINQ method to create your result. ✔
    • Don't forget the list should be unique. ✔
    • It is recommended that, at a minimum, you use ISampleData.GetUniqueSortedListOfStatesGivenCsvRows to validate your result. ❌ wasn't used to validate result
  7. Given the implementation of Node in Assignment5

  • Implement IEnumerable<T> to return all the items in the "circle" of items. ✔
  • Add an IEnumberable<T> ChildItems(int maximum) method to Node that returns the remaining items with a maximum number of items returned less than maximum.

Extra Credit

  • Implement the homework using async/await and multi-threading by defining a new SampleDataAsync class that implements IAsyncSampleData). Refactor your SampleData and SampleDataAsync classes with minimal duplication. Be sure to refactor your tests to re-use a significant amount of the test code for both implementations. ❌ I'm not sure this is fully async.

Fundamentals

  • Place all shared project properties into a Directory.Build.Props file.
  • Place all shared project items into a Directory.Build.targets file.
  • Ensure nullable reference types is enabled ✔
  • Ensure that you turn on code analysis for all projects(EnableNETAnalyzers) ✔
  • Set LangVersion and the TargetFramework to the latest released versions available (preview versions optional) ✔
  • and enabled .NET analyzers for both projects ✔
  • For this assignment, consider using Assert.AreEqual<T>() (the generic version) ✔
  • All of the above should be unit tested ❌ Wasn't fully united tested
  • Choose simplicity over complexity ✔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants