Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Unit Testing in C# Test Driven Development Green

Jasper Peijer
Jasper Peijer
45,009 Points

For people having issues with the IsOnPath method always returning false.

I came across this issue with the code used in the video, so if you come across this issue. Here's an alternative:

        public bool IsOnPath(MapLocation mapLocation)
        {
            foreach (var loc in pathLocations)
            {
                if (mapLocation.X == loc.X && mapLocation.Y == loc.Y)
                {
                    return true;
                }
            }

            return false;
        }

What it does is it loops over every path location and checks if the given map location's X and Y coordinates are equal to the path location's coordinates. If those match, the method returns true and breaks the loop. If the loop finishes without a single match, it will reach the return false statement, and thus return false.