public void GivenWindsorContainerResolvesUsingContext_WhenObtain_ThenReturnResolvedRepository() { StudentRepository expected = new StudentRepository(MockContext); WindsorContainer.Expect(m => m.Resolve<StudentRepository>(Arg<IDictionary>.Matches(a => MatchDictionary(a)))).Return(expected); StudentRepository actual = Target.Obtain<StudentRepository>(); Assert.AreEqual(expected, actual); }
public void GivenAStudentQueryable_WhenIncludeClassesAndTeachers_ThenGetStudentsWithClassesWithATeacher() { List<Student> items = Target.Items.ToList(); Context = new EducationDataContext(); Target = new StudentRepository(Context); List<Student> expanded = Target.Items.Include("Classes.Teacher").ToList(); Assert.IsTrue(items.Any(s => s.Classes.Count == 0)); Assert.IsTrue(expanded.Any(s => s.Classes.Count > 0)); Assert.IsTrue(expanded.Any(s => s.Classes.All(c => c.Teacher != null))); }
public void InitializeTest() { Context = new EducationDataContext(); Target = new StudentRepository(Context); }
public void InitializeTest() { MockContext = MockRepository.GenerateMock<IEducationContext>(); MockDbSet = MockRepository.GenerateMock<IDbSet<Student>>(); MockContext.Expect(m => m.Students).Return(MockDbSet); Target = new StudentRepository(MockContext); }