0

This is my code:

public int GetTotalIssuedCount()
{
    var storeCode = Store.Current.Code.ToLower();
    return (from i in Context.Instance.EduContainer.IssueDetailsSet
            where i.Status.ToLower() == "issued" && i.Store.Code == storeCode
            select i).Count();
}

This is my test code:

[TestMethod]
public void GetTotalIssuedCountTest()
{
    StoreRepository sr = new StoreRepository();
    Assert.IsInstanceOfType();
}

Which assert method will be appropriate here?

Andrii Kalytiiuk
  • 1,501
  • 14
  • 26
  • Please provide more information about what your method does and what Unit Test should check? It depends on your requirements - which assertion to use. – Andrii Kalytiiuk Jul 13 '13 at 13:07

1 Answers1

2

You need to assert whether count matches what you expect, given underlying data set state:

[TestMethod]
public void GetTotalIssuedCountTest()
{
   // The 5 is exemplary value -
   // you need to determine actual one basing data set contents
   const int expectedIssuedCount = 5;
   var storeRepository = new StoreRepository();
   // Here you'll most likely need to prepare fake data set
   var actualIssuedCount = storeRepository.GetTotalIssuedCount();

   Assert.AreEqual(expectedIssuedCount, actualIssuedCount);
}

To make it work you need to set fake data set (EduContainer.IssueDetailsSet) which your method will access. You'll most likely need mocks together with dependency injection to achieve that.

Community
  • 1
  • 1
k.m
  • 30,794
  • 10
  • 62
  • 86
  • 3
    I have to point out (Since Jon Skeet did to me one time :)) that generally, the assertion signatures are `(expected, actual)`, not `(actual, expected)`. – Simon Whitehead Jul 13 '13 at 12:58
  • @SimonWhitehead: this is indeed true for MSTest (which I assume OP is using). Thanks. – k.m Jul 13 '13 at 13:10