public void TestPasswordCheckerServiceConstructor() { var stub = new FakeRepositoryStub(); var passwordColelction = new List <string> { "123asdfg", "123asdfg1", "asdfgjkl" }; foreach (var password in passwordColelction) { stub.Create(password); } var checker = new PasswordCheckerService(stub, CustomPasswordValidator.Instance); // Get private repository field from PasswordCheckerService using reflection. BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.NonPublic; FieldInfo field = checker.GetType().GetField("passwordRepository", bindFlags); var actual = ((FakeRepositoryStub)field.GetValue(checker)).Passwords; CollectionAssert.AreEqual(passwordColelction, actual); }