public void DepartmentByNameTest() { //Arrange string departmentName = string.Empty; using (IDataContextAsync context = new PrimeActs.Data.Contexts.PAndIContext() as IDataContextAsync) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Department> departmentRepository = new Repository <Department>(context, unitOfWork); ICache cache = Cache.Get(CacheType.Memory); IDepartmentService departmentService = new DepartmentService(departmentRepository, cache); var department = CreateDepartment(); departmentName = department.DepartmentName; departmentService.Insert(department); unitOfWork.SaveChanges(); departmentService.RefreshCache(); } //Act using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Department> departmentRepository = new Repository <Department>(context, unitOfWork); ICache cache = Cache.Get(CacheType.Memory); IDepartmentService departmentService = new DepartmentService(departmentRepository, cache); var department = departmentService.DepartmentByName(departmentName); //Assert Assert.AreEqual(department.DepartmentName, departmentName); } }