问题列表 - 第41068页

通过一个简单的例子学习TDD

我正在尝试学习TDD,但我很难理解我需要编写的一个小应用程序测试的内容/方法.

应用程序的(简化的)规范如下:

它需要从用户那里获取csv文件的位置,word文档mailmerge模板的位置和输出位置.

然后,应用程序将读取csv文件,对于每一行,将数据与单词模板合并并输出到指定的文件夹.

为了清楚起见,我不会问我将如何编写这样的应用程序,因为我确信如果我继续开始,我知道该怎么做.但是,如果我想使用TDD进行操作,那么我会猜测我不想测试读取真正的csv文件,或者测试执行合并的第三方组件或转换为pdf.

我认为只是一些一般的TDD指导将是一个很大的帮助!

c# tdd

23
推荐指数
2
解决办法
2万
查看次数

使用var-keyword自动交换显式类型

我想自动删除所有显式类型,并在一个大解决方案中与var关键字交换它们,例如代替

int a = 1;
Run Code Online (Sandbox Code Playgroud)

我希望有:

var a = 1;
Run Code Online (Sandbox Code Playgroud)

这只是化妆品,解决方案中的代码完美无缺,我只想让事情保持一致,因为我开始使用显式类型,但后来使用了var-keywords.

我猜我必须编写某种代码解析器 - 听起来有点麻烦.有人知道一个简单的解决方案吗?

干杯,克里斯

c# types .net-3.5

1
推荐指数
1
解决办法
145
查看次数

如何在MySQL for Mac上设置默认端口

在OSX上,当我尝试使用以下内容时:

resources.db.adapter = "pdo_mysql"
resources.db.params.dbname = "myDb"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Pdo/Abstract.php on line 129

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Pdo/Abstract.php:129
Stack trace:
#0 /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Pdo/Abstract.php(129): PDO->__construct('mysql:dbname=gl...', 'myDb', '', Array)
#1 /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
#2 /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Abstract.php(858): Zend_Db_Adapter_Pdo_Mysql->_connect()
#3 /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Abstract.php(928): Zend_Db_Adapter_Abstract->quote('asdf@asd...', NULL)
#4 /Library/WebServer/sites/testweb/library/Zend/Db/Select.php(1000): Zend_Db_Adapter_Abstract->quoteInto('email = ?', 'asdf@asd...', NULL)
#5 /Library/WebServer/sites/testweb/library/Zen in /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Pdo/Abstract.php …
Run Code Online (Sandbox Code Playgroud)

mysql zend-framework zend-db

4
推荐指数
2
解决办法
8655
查看次数

如何设置"if object exists"条件?

有没有办法检查对象是否存在?我不断收到"需要对象"的错误.我知道该对象不存在,我想绕过我的代码的一部分,如果是这样的话.我不知道我没有尝试过......

    var codeName = document.getElementById('testCode');
    //I have tried
    if(codeName != null)
    if(codeName.length != 0)
    if(typeOf codeName != 'undefined')
    if(!codeName)
    if(codeName.value != null)
Run Code Online (Sandbox Code Playgroud)

有没有办法看看对象是否存在?

javascript object

5
推荐指数
1
解决办法
1万
查看次数

Windows API W7 JumpList仅适用于.NET?

我正在寻找一种使用Windows API通过普通C或C++使用JumpLists的方法.

代码包似乎只适用于.NET.

无论如何使用C/C++ wothout .NET实现它们?我的意思是这怎么可能:

c c++ winapi windows-7

0
推荐指数
1
解决办法
752
查看次数

C++基础知识,向量,析构函数

我对如何做到这一点的最佳实践感到有些困惑.假设我有一个类,例如分配一些内存.我希望它像汽车一样自我毁灭,但也因为某种原因未知而将它放在矢量中.

 #include <iostream>
 #include <vector>
 class Test {
 public:
  Test();
  Test(int a);
  virtual ~Test();
  int counter;
  Test * otherTest;
 };

 volatile int count = 0;


 Test::Test(int a) {
  count++;
  counter = count;
  std::cout << counter <<  "Got constructed!\n";
  otherTest = new Test();
  otherTest->counter = 999;
 }

 Test::Test() {
  count++;
  counter = count;
  std::cout << counter <<  "Alloced got constructed!\n";
  otherTest = NULL;
 }


 Test::~Test() {
  if(otherTest != 0){
  std::cout << otherTest->counter << " 1Got destructed" << counter << "\n";
  otherTest->counter …
Run Code Online (Sandbox Code Playgroud)

c++

1
推荐指数
1
解决办法
372
查看次数

网页必须以".php"结尾才能运行php代码吗?

网页是否需要以".php"结尾才能运行php代码?有没有办法以".html"结尾的文件可以运行PHP代码?

html php

5
推荐指数
2
解决办法
1998
查看次数

滚动UITableView时隐藏键盘

在我的应用程序中,当我开始滚动UITableView时,我想隐藏键盘.我在互联网上搜索这个,大多数答案是子类化UITableView(http://stackoverflow.com/questions/3499810/tapping-a-uiscrollview-to-hide-the-keyboard).

我做了子类但它不起作用.

#import <UIKit/UIKit.h>

@protocol MyUITableViewDelegate <NSObject>
@optional
- (void)myUITableViewTouchesBegan;
@end

@interface MyUITableView : UITableView <UITableViewDelegate, UIScrollViewDelegate> {
    id<MyUITableViewDelegate> delegate;
}
@end
Run Code Online (Sandbox Code Playgroud)

.m文件

#import "MyUITableView.h"

@implementation MyUITableView

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    NSLog(@"delegate scrollView"); //this is dont'work
    [super scrollViewDidScroll:scrollView];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"delegate myUITableViewTouchesBegan"); // work only here
    [delegate myUITableViewTouchesBegan];
    [super touchesBegan:touches withEvent:event];

}

- (void)dealloc {
...
Run Code Online (Sandbox Code Playgroud)

我像这样使用这个类.但委托函数myUITableViewTouchesBegan在ViewController中不起作用

.H

#import <UIKit/UIKit.h>
#import "MyUITableView.h"

@interface FirstViewController : UIViewController <UITableViewDelegate, UISearchBarDelegate, MyUITableViewDelegate> {
    MyUITableView *myTableView;
    UISearchBar *searchBar; 
}

@property(nonatomic,retain) …
Run Code Online (Sandbox Code Playgroud)

keyboard scroll uitableview ios

124
推荐指数
5
解决办法
6万
查看次数

jquery,从名称标签中提取数字值

我有这个是由我的perl脚本创建的.

    print qq|
        \$('textarea[name=category$row[0]]').keydown(function(event)
         {
            \$("input[value=$row[0]]").attr('checked', true);
        });
    |;
Run Code Online (Sandbox Code Playgroud)

某个地方以后,我有这个,我想重新提取$ row [0]值,但我不确定如何在jquery中.

print qq|
<script>
    \$('#display_category').change(function() {
        var text = \$(this).val();

        \$('textarea[name^="category"]').each(function() {
            var foundvalue = \$(this).val();

            if (text == foundvalue)
            {
                alert("FOUND HERE " + foundvalue);

            }
        });
    });
</script>

|;
Run Code Online (Sandbox Code Playgroud)

如何从类别中重新提取\ d +并在if条件下使用它?

javascript jquery

3
推荐指数
1
解决办法
785
查看次数

是否有一个用 PHP 编写的轻量级 sql 解析器类可以做到这一点?

在我自己动手之前,我想我应该先在这里问一下。

我希望对随机 SQL 命令进行一些基本解析,以便:

  1. 检查“SELECT”中使用的字段名称(包括任何子查询)
  2. 检查“JOIN”中使用的字段名称(包括任何子查询)
  3. 检查查询中使用的表的名称(包括任何子查询)

我见过一些 SQL 解析器类,但它们对于上述用例来说太“重量级”了。

有人知道至少具有一些所需功能的轻量级类吗?

最坏的情况,如果我必须编写一个解析器,那么编写这样一个解析器的最佳方法是什么(通常,要编写一个解析器,我通常会使用 PHP 中不可用的工具),关于如何编写解析器的任何提示编写一个“粗略且准备就绪”的类来进行此解析?

//rough sketch
<?php
class SqlParser()
{
    protected $sqlstr;
    protected $m_tablenames = array();
    protected $m_fieldnames = array();

    public function __construct($sql){
       $this->sqlstr = $sqlcmd;
       $this->parseString($sqlstr);
    }

    public function __destroy(){}
    public function getTableNames(){ return m_tablenames; }
    public function getFieldNames(){ return m_fieldnames; }

    private function parseString($sql)
    {
        //TODO
    }
}

?>
Run Code Online (Sandbox Code Playgroud)

我希望解析尽可能与 SQL 方言无关(即不依赖于任何特定的 SQL 方言或数据库特定的 SQL)。

如果这是不可能的,那么我将使用的 SQL 方言是 PostgreSQL。

php sql postgresql

6
推荐指数
1
解决办法
4526
查看次数