Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi
I have install Nunit when i am running this nunit it gives me some error and the error i am getting is "This assembly was not built with any known testing framework" and in c# in reference i am adding the .net framework and in that i am not getting .dll file i have even browser an try to put from program files but it is not showing me in reference folder please let me know what i do in this case?

When i am writing this code:
C#
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
        }

        public float balance;

        public void Deposite(float amount)
        {
            balance += amount;
        }

        public void withdraw(float amount)
        {
            balance -= amount;
        }

        public void TransferFunds(Program destination, float amount)
        {
        }

        public float Balance
        {
            get { return balance; }
        }

        public static void testmethod()
        {
            Program a1 = new Program();
            a1.Deposite(200.00f);
            Program a2 = new Program();
            a2.Deposite(15.00f);
            a1.TransferFunds(a2, 100.00f);
            Program.Equals(250.00f, a2.balance);
            Program.Equals(100.00f, a1.balance);
        }
    }

    [TestFixture()]
    public class Calculator_UnitTest
    {
        Program a1 = new Program();

        [SetUp()]
        public void Init()
        {
            // some code here, that need to be run
            // at the start of every test case.
        }

        [TearDown()]
        public void Clean()
        {
            // code that will be called after each Test case
        }

        [Test]
        public void Test()
        {
            Program a1 = new Program();
            a1.Deposite(200.00f);
            Program a2 = new Program();
            a2.Deposite(15.00f);
            a1.TransferFunds(a2, 100.00f);
            Program.Equals(250.00f, a2.balance);
            Program.Equals(100.00f, a1.balance);
       }
   }
}

It's not supporting NUnit.Framework nor [TestFixture()] and all please help.
Posted
Updated 2-Oct-10 10:04am
v4
Comments
Toli Cuturicu 2-Oct-10 16:06pm    
NUnit is a third party assembly. It is not part of the .NET Framework.
So, it may be better to ask for support the people who wrote and distribute NUnit.
aayu 4-Oct-10 9:37am    
Well i know that NUnit is third party assembly but it do support .Net well i have done RND we can write code in Console Application for that we have to put reference of .Net Framework OR if we want we can your class lib for that so it can be easy for readability. and to understand for the people who is going through code.

1 solution

Try to split the program *project* from the test project. I.e. make two projects in your solution: one with the productive code (e.g. a console app assembly or a lib assembly) and one with the test assembly (a lib assembly). The test assembly should reference the productive assembly and the test code should call the to-be-tested methods of the productive assembly.

Check also the properties of your project(s). The build tab (e.g. in VS2010) should show some supported Framework version, e.g. .Net Framework 4.

Cheers

Andi
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900