我想为截取Loggable基类(实现ILoggable)的拦截器编写一些单元测试.
在可记录的基类有没有方法来调用,它仅用于通过登录基础设施进行初始化.
根据我的理解,我应该:
问题是我的ILoggable接口没有可以调用的方法,因此不会截获任何内容.
在这里采取行动的正确方法是什么?
我应该手动模拟ILoggable并添加一个存根方法来调用吗?
另外,我也应该嘲笑容器吗?
我正在使用Moq和NUnit.
编辑:
这是我的拦截器实现参考:
public class LoggingWithDebugInterceptor : IInterceptor
{
#region IInterceptor Members
public void Intercept(IInvocation invocation)
{
var invocationLogMessage = new InvocationLogMessage(invocation);
ILoggable loggable = invocation.InvocationTarget as ILoggable;
if (loggable == null)
throw new InterceptionFailureException(invocation, string.Format("Class {0} does not implement ILoggable.", invocationLogMessage.InvocationSource));
loggable.Logger.DebugFormat("Method {0} called with arguments {1}", invocationLogMessage.InvokedMethod, invocationLogMessage.Arguments);
Stopwatch stopwatch = new …Run Code Online (Sandbox Code Playgroud) 谁能告诉我怎么能够estabilish 1 to 0..1和1 to 1..*表中的SQL(服务器)之间的关系?
非常感谢你.
我正在为我正在研究的项目编写框架组件,我想知道是否可以在没有服务器的情况下在本地托管NuGet包,这样我就可以通过使用我的计算机来创建完整的发布周期.
如果可能,请解释如何操作.
什么是创建对象的RESTful方法?我应该在/ resources/URI上使用POST并将URI返回到响应中新创建的资源,还是应该在/ resources/id/URI上使用PUT?对/ resources/id /的GET请求肯定会返回404,但是PUT也应该返回404吗?两种方法都应该用于创建新对象吗?
我有以下 pxd 标头,它增强了常规 Python 模块:
#!/usr/bin/env python
# coding: utf-8
cimport cython
@cython.locals(media_type=unicode, format=unicode, charset=unicode, render_style=unicode)
cdef class BaseRenderer(object):
"""
All renderers should extend this class, setting the `media_type`
and `format` attributes, and override the `.render()` method.
"""
@cython.locals(indent=int, separators=tuple)
cpdef object render(self, dict data, accepted_media_type=?, renderer_context=?)
@cython.locals(compact=bool, ensure_ascii=bool, charset=unicode)
cdef class JSONRenderer(BaseRenderer):
@cython.locals(base_media_type=unicode, params=dict)
cpdef int get_indent(self, unicode accepted_media_type, dict renderer_context)
@cython.locals(callback_parameter=unicode, default_callback=unicode)
cdef class JSONPRenderer(JSONRenderer):
cpdef unicode get_callback(self, dict renderer_context)
Run Code Online (Sandbox Code Playgroud)
在 Python 2 中,该render()方法可能返回字符串、字节或 unicode,但在 Python …
此SQL查询由SQL Server Managment Studio生成,它会抛出一个错误:
USE [database_name]
GO
/****** Object: Table [dbo].[UserAddress] Script Date: 02/17/2010 11:21:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[UserAddress]
(
[ID] [int] IDENTITY(1,1) NOT NULL,
[UserID] [int] NULL,
[AddressName] [nvarchar](25) NULL,
[Fname] [nvarchar](15) NULL,
[LName] [nvarchar](20) NULL,
[City] [nvarchar](15) NULL,
[Street] [nvarchar](30) NULL,
[StreetNum] [nvarchar](5) NULL,
[FloorNum] [int] NULL,
[AptNum] [int] NULL,
[ZipCode] [int] NULL,
[Phone] [varchar](15) NULL,
[Phone_Prefix] [int] NULL,
[CellPhone] [varchar](15) NULL,
[CellPhone_Prefix] [int] NULL,
[Fax] …Run Code Online (Sandbox Code Playgroud) 我有两个数组,我想将一个数组追加到另一个数组的末尾.我该怎么做呢?
self.itemsCopy = [self.items mutableCopy];
Run Code Online (Sandbox Code Playgroud)
将复制数组,但我想追加self.items.
我有一些类需要可靠性来将所有公共属性从一个对象复制到另一个对象.
每个类都有一组可能与其他类不同的公共属性.
例:
class Base
{
// Common properties/methods...
public void Copy<T>(T data) where T : Base
{
// ...
}
}
class D1 : Base
{
public int ID
{
get;
set;
}
}
class D2 : Base
{
public string Name
{
get;
set;
}
}
Run Code Online (Sandbox Code Playgroud)
通过谷歌搜索我已经阅读了这些方法:
所有这些都非常复杂或非常慢或有时两者兼而有之.
我错过了什么吗?有没有其他方法来访问原始this指针?
编辑:
我会clerify.
T是调用类的类型.例如,如果它被D1调用,则T将始终为D1.
通用的原因是我不知道T是什么.
我错过了什么吗?
我应该Base data用作参数吗?
我有以下功能signuture:
public JsonResult PopulateGrid(int page, Guid? accountId, Guid? systemUserId, Guid? branchId, DateTime? fromDate, DateTime? toDate, HomeVisitType? homeVisitType)
Run Code Online (Sandbox Code Playgroud)
每个参数都绑定得很好,除非toDate结果总是为null.
检查时,Request.QueryString["toDate"]它会检索正确的值,即30/09/2010.
似乎DateTime在绑定时需要另一种格式.
什么是正确的格式?
string strArr="5,3,8,1,9,2,0,6,4,7";
Run Code Online (Sandbox Code Playgroud)
我想重新排列数字的顺序,所以结果将如下所示:
string result ="0,1,2,3,4,5,6,7,8,9";
Run Code Online (Sandbox Code Playgroud)
任何的想法?
.net ×2
c# ×2
sql ×2
sql-server ×2
asp.net-mvc ×1
cocoa ×1
create-table ×1
cython ×1
datetime ×1
mocking ×1
nuget ×1
objective-c ×1
python ×1
python-2.7 ×1
python-3.x ×1
rdbms ×1
rest ×1
shallow-copy ×1
unit-testing ×1