public void AddRangeStateTest() { //country table must NOT be Empty var context = new ApplicationDbContext(); var target = new StateRepository(context); var countryId = context.Country.FirstOrDefault().Id;//select first row from Country Table, For Country id IList <State> stateList = new List <State>(); var state1 = new State() { CountryId = countryId, Title = "Gilan" }; var state2 = new State() { CountryId = countryId, Title = "Tehran" }; stateList.Add(state1); stateList.Add(state2); var expected = context.State.Count() + stateList.Count; target.AddRange(stateList); target.Complete(); var actual = context.State.Count(); Assert.AreEqual(expected, actual);//if expected equals to actual then the test would pass }