问题列表 - 第32876页

单元测试规则

对于你们中的一些人,我的问题可能显得非常愚蠢,但我不得不问......抱歉..

I don't really understand principles of unit testing.. How can you test classes of your business classes or Data access layer without modify your database? I explain, i have a functionality who update a field in a database.. Nothing so amazing.. The Business layer class is instantiated and the method BLL.Update() makes some controls and finally instantiate a DAL class who launch a stored procedure in the database with the correct parameters.

Its works but my question is..

To …

c# unit-testing

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

Erlang Error Handling , X unsafe in 'try'

Can anyone enlighten me as to why this bit of code spits back that the X is unsafe in 'try', well I know why, but more so how to fix it.

try X = lists:append(lists:zipwith3(fun(X, Y, Z) -> [X, Y, Z] end, Data1, Data2, Data3)) of
            MP -> X
            catch K -> (X = 0)
            end.
            %MP = [lists:zipwith3(X, Y, Z) || X, Y, Z <-  [Data1, Data2, Data3]],


P = X
Run Code Online (Sandbox Code Playgroud)

erlang try-catch

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

How to iterate through range of Dates?

In my script, I need to iterate through a range of dates given the start date and end date. How can I do this in Perl?

windows perl

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

19
推荐指数
2
解决办法
4670
查看次数

Silverlight HTTP POST少数变量,SIMPLEST示例(最少代码)

您好我想将一些来自silverlight的数据发布到网站上.
我找到了以下链接,它的工作原理......
但......这个例子非常详细,让我的眼睛受伤了.
另外.. flex示例更清洁/更少代码..

我会说必须有更好的解决方案......

供参考..我们发布2个变量(字符串)并读出结果(字符串).

来自链接的解决方案:

   1. // C#  
   2. // Create a request object  
   3. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(POST_ADDRESS, UriKind.Absolute));  
   4. request.Method = "POST";  
   5. // don't miss out this  
   6. request.ContentType = "application/x-www-form-urlencoded";  
   7. request.BeginGetRequestStream(new AsyncCallback(RequestReady), request);  
   8.   
   9. // Sumbit the Post Data  
  10. void RequestReady(IAsyncResult asyncResult)  
  11. {  
  12.     HttpWebRequest request = asyncResult.AsyncState as HttpWebRequest;  
  13.     Stream stream = request.EndGetRequestStream(asyncResult);  
  14.   
  15.     // Hack for solving multi-threading problem  
  16.     // …
Run Code Online (Sandbox Code Playgroud)

c# silverlight http

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

如何在Python中将日期时间字符串中的时间从24:00转换为00:00?

我有很多日期字符串Mon, 16 Aug 2010 24:00:00,其中一些是00-23小时格式,其中一些是01-24小时格式.我想获得它们的日期对象列表,但是当我尝试将示例字符串转换为日期对象时,我必须将其转换Mon, 16 Aug 2010 24:00:00Tue, 17 Aug 2010 00:00:00.什么是最简单的方法?

python datetime

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

为什么我需要内存屏障?

Nutshell中的C#4(强烈推荐的btw)使用以下代码来演示MemoryBarrier的概念(假设A和B在不同的线程上运行):

class Foo{
  int _answer;
  bool complete;
  void A(){
    _answer = 123;
    Thread.MemoryBarrier(); // Barrier 1
    _complete = true;
    Thread.MemoryBarrier(); // Barrier 2
  }
  void B(){
    Thread.MemoryBarrier(); // Barrier 3;
    if(_complete){
      Thread.MemoryBarrier(); // Barrier 4;
      Console.WriteLine(_answer);
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

他们提到障碍1和4阻止这个例子写0和障碍2和3提供新鲜度保证:他们确保如果B在A之后运行,读_complete将评估为.

我不是真的得到它.我想我明白为什么壁垒1和4是必要的:我们不想在写_answer进行优化,并放置在写后_complete(屏障1),我们需要确保_answer没有被缓存(光栅4) .我也认为我理解为什么Barrier 3是必要的:如果A在写完_complete = true之后才运行,B仍然需要刷新_complete以读取正确的值.

我不明白为什么我们需要障碍2!我的一部分说这是因为可能线程2(运行B)已经运行直到(但不包括)if(_complete),因此我们需要确保_complete被刷新.

但是,我不知道这有多大帮助.是不是仍然可以在A 中将_complete设置为true但是B方法会看到_complete的缓存(错误)版本?即,如果线程2运行方法B直到第一个MemoryBarrier之后,然后线程1运行方法A直到_complete = true但没有进一步,然后线程1恢复并测试是否(_complete) - 如果不导致错误 …

c# multithreading thread-safety shared-memory memory-barriers

34
推荐指数
2
解决办法
9488
查看次数

使用ninject的WinForms对话框的最佳实践是什么?

我尝试用Ninject创建应用程序.我有一个MainForm用于设置的对话框表单.我应该如何实现这个?应该MainForm有一个Kernel实例,然后SettingsFormGet<SettingsForm>()方法创建?或者MainForm构造函数应该具有SettingsForm实例参数?

我尝试用ninject找到一些WinForm应用程序的例子,但我发现只有一些ASP.NET应用程序在Visual C#2008 express中没用.

c# ninject winforms

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

为什么使用CakePhp AJAX助手代替jQuery?

我刚刚开始使用cakePHP,我看到其中有一个AJAX Helper.

我的问题很简单:我应该使用这个帮助器,还是应该继续使用jQuery进行AJAX?我应该在现有的jQuery AJAX调用中执行任何更改吗?

谢谢

ajax jquery cakephp helper

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

C#函数重载规则

有关函数重载的规则是什么?

我有以下代码:

public T genericFunc<T>() where T : Component, new()
{
    T result = new T();
    overloadedFunction( result );
}

private overloadedFunction ( Component c ) // catch all function

private overloadedFunction ( DerivedFromComponent dfc) // specific function
Run Code Online (Sandbox Code Playgroud)

当我用以下代码调用上面的代码时:

genericFunc<DerivedFromComponent>();
Run Code Online (Sandbox Code Playgroud)

我希望调用更具体的overloadedFunction,但是会调用catch all函数,为什么会这样?单步执行上面的代码时,类型T确实是DerivedFromComponent,我认为CLR在运行时选择了最佳匹配!

c# clr overloading

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