Click here to Skip to main content
15,668,691 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have one question. What is good testing way, Microsoft.VisualStudioTestToolsUnitTesting or by Nunit_framework testing.

If I have this`

public Branch CreateOrEditBranch(Branch branch)
       using (var scope = CreateTransactionScope())

       return branch;
I have branch metod. and branch have properties(name,user,adress and so) , and positive test need be if all properties will be full, if not,then it will be negative test , after it will show msg , that something is wrong.

Now how can i wrote this test by good way. i wrote it like this `

public void BranchTest()
        try {

              Branch negative = new Branch()

                  AccountantPost = "Post",

                  Accountant = "Accoutant"`,

                  Address = "Address",

                  BankCode = "Code",

                  Manager = "Manager",

                  ManagerPost = "Post",

                 OpenDate = DateTime.Now,

                 CloseDate = DateTime.Today,

                 User = "marin",

                 Modified = DateTime.Now,




catch (Exception ex)


Is it right ?
I hope someone can help me :(

Thank you.
Updated 4-Aug-14 4:08am

1 solution

Hi You can check for null conditions of each of the variables using an AND condition as shown below:

bool? isValid = null;
Branch positive = new Branch();
// Assign values to the instance here.
isValid = positive.BranchID != null && positive.Address != null && positive.BankCode != null;
Assert.AreEqual(true, isValid);
Share this answer
Marine Azizyan 5-Aug-14 2:37am    
Thank you very much .
Vijendra(VJ) 5-Aug-14 3:50am    
Can you please accept this as answer if this works for you.
Vijendra(VJ) 8-Aug-14 5:33am    
whats the problem Mr. Marine Azizyan?
Isnt this working ?
Marine Azizyan 8-Aug-14 7:11am    
No, already i finded solution for it. So your wrote code isn't working like a test, anytime thank you.

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