我有这个接口,在我想模拟的一些函数中返回void,并想知道这样做的正确方法是什么.截至目前,我有以下内容:
var mocks = new MockRepository();
var mockedInterface = mocks.CreateMock<IMyInterface>();
Expect.Call(mockedInterface.FunctionThatReturn(param1, param2)).Return(Something);
mockedInterface.FunctionReturningVoid(param3, param4);
mocks.ReplayAll();
// Some assert and other stuff
mocks.VerifyAll();
Run Code Online (Sandbox Code Playgroud)
这是正确的做法吗?我觉得它看起来很奇怪,因为你没有以同样的方式处理这两个函数.我想写的是:
var mocks = new MockRepository();
var mockedInterface = mocks.CreateMock<IMyInterface>();
Expect.Call(mockedInterface.FunctionThatReturn(param1, param2)).Return(Something);
Expect.Call(mockedInterface.FunctionReturningVoid(param3, param4)); // This doesn't work.
mocks.ReplayAll();
// Some assert and other stuff
mocks.VerifyAll();
Run Code Online (Sandbox Code Playgroud)
但这不适用于第4行.我发现一些博客说你可以使用lambda(或委托)之类的
Expect.Call(() => mockedInterface.FunctionReturningVoid(param3, param4)); // This doesn't work.
Run Code Online (Sandbox Code Playgroud)
但这对我来说似乎不起作用.拥有Expect.Call
它可以轻松识别模拟功能,这就是我想要的原因.我得到的编译错误是:"无法将lambda表达式转换为类型'对象',因为它不是委托类型".
那怎么办呢?
更新:添加了编译错误信息.
如何在一个文件中定义多个媒体查询?
我有这个.styl文件:
@media (min-width: 980px)
body
padding-top 60px
@media (min-width: 768px)
body
.container
width 768px
Run Code Online (Sandbox Code Playgroud)
这给了我错误expected "indent", got "newline"
.将它们放在单独的文件中并拥有一个文件包括其他工作.但是当我将它们放在同一个文件中并且第二个文件导入这个文件时它会失败.
更新:文件的代码可以在这里找到:
如何Application_Error
在ASP.NET WebAPI应用程序中获取触发器?我现在遇到的错误是当我们通过NInject解析控制器并且失败时它将无法进入Application_Error
,我们无法记录错误,因为我们正在进行全局登录Application_Error
.
我们还有一个用于处理错误的全局过滤器,但只有在找到控制器时才触发,但由于我们失败了,我们实例化控制器,我们不会通过任何过滤器.
那么我如何捕获Exception
为什么尝试创建处理响应的控制器呢?
我一直在尝试使用模型绑定来使我们的API易于使用。使用API时,只有当数据在查询中时,我才能使模型绑定在主体中进行绑定。
我的代码是:
public class FunkyModelBinder : IModelBinder
{
public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
{
var model = (Funky) bindingContext.Model ?? new Funky();
var hasPrefix = bindingContext.ValueProvider
.ContainsPrefix(bindingContext.ModelName);
var searchPrefix = (hasPrefix) ? bindingContext.ModelName + "." : "";
model.Funk = GetValue(bindingContext, searchPrefix, "Funk");
bindingContext.Model = model;
return true;
}
private string GetValue(ModelBindingContext context, string prefix, string key)
{
var result = context.ValueProvider.GetValue(prefix + key);
return result == null ? null : result.AttemptedValue;
}
}
Run Code Online (Sandbox Code Playgroud)
当在寻找ValueProvider
的财产bindingContext
我只看到QueryStringValueProvider …
我刚刚安装了Xamarin工作室来试用OSX上的F#体验.安装工作正常,我能够创建F#教程项目,但当它尝试打开Tutorial.fs文件时,我收到以下消息:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMethodException: Method not found: 'Mono.TextEditor.Highlighting.ResourceXmlProvider.Open'.
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
at Mono.Addins.TypeExtensionNode.CreateInstance () [0x00000] in /Users/builder/data/lanes/monodevelop-lion-evolve_fixed/a8bf58d3/source/monodevelop/main/external/mono-addins/Mono.Addins/Mono.Addins/TypeExtensionNode.cs:93
at MonoDevelop.SourceEditor.SyntaxModeCodon.get_SyntaxMode () [0x00000] in …
Run Code Online (Sandbox Code Playgroud) 我已经开始关注MassTransit并且正在编写将处理消息的类.当我实现接口从Consumes<T>
我得到的四个选项:All
,Selected
,For<T>
和Context
.它们之间有什么区别?它们何时应该使用?
我正在尝试使用BigQueryOperator
。我以为以后会使用google composer,但我希望它先在本地运行。我可以顺畅运行并且运行BashOperator
良好,也可以airflow test <dag> <task>
在task
要运行的大查询任务所在的位置运行,但是当我从UI触发DAG时,bigquery任务永远不会排队。相反,它们具有REMOVED
状态,什么也没有发生。
我的DAG定义如下:
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta
from airflow.contrib.operators.bigquery_operator import BigQueryOperator
yesterday = datetime.combine(
datetime.today() - timedelta(1),
datetime.min.time())
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'email': ['airflow@example.com'],
'start_date': yesterday,
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5),
}
with DAG(
'tutorial', default_args=default_args) as dag:
operators
t1 = BashOperator(
task_id='print_date',
bash_command='date')
template_sql = '''
SELECT 'TOMAS' name, '{{ params.my_value …
Run Code Online (Sandbox Code Playgroud) 如何使用反射设置枚举,
我的班级有枚举:
public enum LevelEnum
{
NONE,
CRF,
SRS,
HLD,
CDD,
CRS
};
Run Code Online (Sandbox Code Playgroud)
并且在运行时我想将该枚举设置为CDD for ex.
我该怎么做 ?
我想用PowerShell将我的应用程序部署到azure.到目前为止,我已在localmachine商店中创建了一个证书,我不会像我一样运行部署脚本,将脚本上传到azure.下一步是在powershell中访问azure上的服务,但它失败了.我到目前为止的脚本是:
$cert = Get-Item Cert:\LocalMachine\deploy\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Set-AzureSubscription -SubscriptionName $subscriptionName -SubscriptionId $subscriptionId -Certificate $cert
Select-AzureSubscription $subscriptionName
$service = Get-AzureService $azureId
Run Code Online (Sandbox Code Playgroud)
它在最后一行失败,并显示以下消息:
Get-AzureService : Communication could not be established. This could be due to an invalid subscription ID. Note that subscription IDs are case sensitive.
At F:\DeployTest\deploy.ps1:9 char:12
+ $service = Get-AzureService $azureId
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-AzureService], Exception
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Management.ServiceManagement.HostedServices.GetAzureServiceCommand
Get-AzureService : HTTP Status Code: AuthenticationFailed - HTTP Error Message: The server failed to authenticate the request. …
Run Code Online (Sandbox Code Playgroud) 到目前为止,我有一个带有超级简单搜索字段的顺风项目。当选择此搜索字段时,我希望减小边框半径(使其更像正方形),应用颜色和其他一些小东西。这种过渡似乎适用于除边界半径之外的所有内容。
\n我的标记如下所示:
\n<input\n type="text" \n className="transition-border duration-500 rounded-full bg-secondary-neutral pl-4 pr-14 py-2 outline-0 focus:border focus:border-accent-neutral focus:rounded-sm focus:bg-white focus:shadow-primary-extra-light focus:shadow-md text-sm text-ellipsis w-full max-w-sm"\n placeholder="S\xc3\xb8k etter produkter, merker og mer"\n/>\n
Run Code Online (Sandbox Code Playgroud)\n我还将其添加到我的 tailwind 配置中以获取边框过渡:
\ntransitionProperty: {\n 'border': 'border,border-radius,box-shadow,background-color',\n},\n
Run Code Online (Sandbox Code Playgroud)\n输入字段的相关生成的 css 如下所示:
\n.duration-500 {\n transition-duration: 500ms;\n}\n.transition-border {\n transition-property: border,border-radius,box-shadow,background-color;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n}\n
Run Code Online (Sandbox Code Playgroud)\n为了在边界半径上获得动画,我还缺少什么?
\nasp.net ×2
c# ×2
.net ×1
airflow ×1
azure ×1
c#-2.0 ×1
c#-3.0 ×1
c#-4.0 ×1
css ×1
f# ×1
masstransit ×1
mocking ×1
mono ×1
powershell ×1
rhino-mocks ×1
stylus ×1
tailwind-css ×1