I've already read posts about referencing the namespaces of the programs with the "using" statements at the top of the program here and here and here. I've added the appropriate references, made the classes public, and referenced the appropriate namespaces. I believe I've set it up right... and I honestly feel a bit silly asking such a basic question here, but I'm stumped. I must be missing something, because it's still not working, and I can't figure it out.
I'm trying to learn how to use Nunit to run unit tests while having separation of the tests from the main program. Here's the code I've got so far:
Program.cs and Account.cs are in the first project (NUnitTestProgramWithSeparation)
Program.cs --
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NUnitTestProgramWithSeparation
{
public class MyAccountingSoftware
{
public static void Main()
{
Account DemoAccount = new Account();
DemoAccount.Deposit(1000.00F);
DemoAccount.Withdraw(500.50F);
Console.WriteLine("Our account balance is {0}", DemoAccount.Balance);
}
}
}
Account.cs --
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NUnitTestProgramWithSeparation
{
public class Account
{
private float balance;
public void Deposit(float amount)
{
balance += amount;
}
public void Withdraw(float amount)
{
balance -= amount;
}
public void TransferFunds(Account destination, float amount)
{
}
public float Balance
{
get { return balance; }
}
}
}
Then, in a second project called UnitTests I have UnitTests.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using NUnitTestProgramWithSeparation;
namespace UnitTests
{
[TestFixture]
public class UnitTests
{
[Test]
public void TransferFunds()
{
Account source = new Account();
source.Deposit(200.00F);
Account destination = new Account();
destination.Deposit(150.00F);
source.TransferFunds(destination, 100.00F);
Assert.AreEqual(250.00F, destination.Balance);
Assert.AreEqual(100.00F, source.Balance);
}
[Test]
public void DepositFunds()
{
Account source = new Account();
source.Deposit(200.00F);
Assert.AreEqual(200.00F, source.Balance);
}
}
}
When I go to compile, I get errors in for all the Account references in UnitTest.cs saying "The type or namespace name 'Account' could not be found (are you missing a using directive or an assembly reference?)"
I really don't know where I'm going wrong here... any help at all would be appreciated.