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 trialElizabeth Fust
9,651 PointsI don't know why I'm getting this error on Task 1 of 4 of TDD section of C# Unit Testing course
I'm supposed to "Stub out the Calculator class so that the code compiles, but the test cases in CalculatorTests fail as expected." I'm getting the following error: "CalculatorTests.cs(18,16): error CS1061: Type Calculator' does not contain a definition for
Add' and no extension method Add' of type
Calculator' could be found. Are you missing an assembly reference?
Calculator.cs(3,14): (Location of the symbol related to previous error)."
It is referring to the line in CalculatorTests.cs where it says target.Add.
I barely understand what I'm doing, so this error has me at a complete loss for what to do.
using System;
public class Calculator
{
public double Result;
public Calculator(double value)
{
Result = value;
}
public void Initialization()
{
}
public double BasicAdd(double value)
{
return Result += value;
}
}
using Xunit;
public class CalculatorTests
{
[Fact]
public void Initialization()
{
var expected = 1.1;
var target = new Calculator(1.1);
Assert.Equal(expected, target.Result, 1);
}
[Fact]
public void BasicAdd()
{
var target = new Calculator(1.1);
target.Add(2.2);
var expected = 3.3;
Assert.Equal(expected, target.Result, 1);
}
}
1 Answer
Elizabeth Fust
9,651 PointsNevermind. I figured it out