在我的一个单元测试文件中,我不得不使用不同的模拟对同一服务进行多次模拟。
import { MyService } from '../services/myservice.service';
import { MockMyService1 } from '../mocks/mockmyservice1';
import { MockMyService2 } from '../mocks/mockmyservice2';
describe('MyComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
MyComponent
],
providers: [
{ provide: MyService, useClass: MockMyService1 }
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(MapComponent);
mapComponent = fixture.componentInstance;
fixture.detectChanges();
});
describe('MyFirstTest', () => {
it('should test with my first mock', () => {
/**
* Test with my first mock
*/
});
});
describe('MySecondTest', () => …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 ASP.Net WebApi 在我的应用程序中使用单元模式实现域驱动设计。
1) 我应该从哪里开始/提交事务(API 控制器、应用层/服务、DAL、域层/服务)?
2)在具有大量业务规则(AOP、显式调用或其他方式)的复杂应用程序中管理事务的最佳方法是什么?
3)在更大的事务中重用一段带有事务的代码的最佳方法是什么? ig 我有独立的用例 - 关闭发票 - 已经包含交易。此代码还包含一些非域代码,如日志记录、统计计数等。我想在更复杂的用例中重用此代码 - 支付发票、扣除佣金和关闭发票。
3.1)如何处理内部事务问题(流行数据库不支持)?
3.2)层应该为此负责什么?
我知道答案可能取决于特定项目。但是在实际项目中考虑任何可行的技术会很棒
我试图通过此帖子用ASOS强加OpenID Connect服务器(资源所有者密码凭据授予)。当我在一个应用程序中同时拥有授权服务器和资源服务器时,一切工作正常。但是,当我在两个应用程序(但在一台机器上)上拆分它们时,资源服务器无法验证令牌并返回访问令牌无效。
我下载了的源代码AspNet.Security.OAuth.Validation以调查此问题,并在此处返回null
以下是来自授权服务器的一些日志:
信息:Microsoft.AspNetCore.Hosting.Internal.WebHost [1]
请求启动HTTP / 1.1 POST http:// localhost:5000 / connect / token application / x-www-form-urlencoded; 字符集= UTF-8 77
信息:AspNet.Security.OpenIdConnect.Server.OpenIdConnectServerMiddleware [0]
令牌请求已成功从HTTP请求中提取:{
“ grant_type”:“密码”,
“ username”:“ UserLogin”,
“ password”:“ [出于安全原因被删除]”,
“ scope”:“ offline_access”
}。
信息:AspNet.Security.OpenIdConnect.Server.OpenIdConnectServerMiddleware [0]
令牌请求已成功验证。
记录:AspNet.Security.OpenIdConnect.Server.OpenIdConnectServerMiddleware [0]
触发了登录操作:子:123,用户名:UserLogin; [.scopes,[“电子邮件”,“个人资料”,“离线访问”]],[。resources,[“ resource_server”]]。
dbug:Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository [37]
从文件'C:\ Users \ User1 \ AppData \ Local \ ASP.NET \ DataProtection-Keys \ key-********-****-****-****-中读取数据64bb57db1c3b.xml”。
dbug:Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager [18]
找到了密钥{********-****-****-****-64bb57db1c3b}。
dbug:Microsoft.AspNetCore.DataProtection.KeyManagement.DefaultKeyResolver [13]
将失效日期为2017-09-27 16:44:49Z的密钥{********-****-****-****-****-64bb57db1c3b}作为默认密钥。
dbug:Microsoft.AspNetCore.DataProtection.XmlEncryption.DpapiXmlDecryptor [51]
使用Windows … 根据这篇文章
Shared (S) - 用于不更改或更新数据的操作(只读操作),例如 SELECT 语句。
根据这篇文章
当排他 (X) 锁被持有时,在排他 (X) 锁被释放之前,任何其他事务都不能在该资源上获取任何类型的锁(共享、更新或排他)。
因此,在第一个会话中,我运行以下代码:
begin tran
select *
from SomeTable with (xlock)
waitFor delay '00:00:05'
commit tran
Run Code Online (Sandbox Code Playgroud)
当第一个事务运行时,我在第二个会话中运行以下代码:
begin tran
select * from SomeTable
commit tran
Run Code Online (Sandbox Code Playgroud)
我立即看到 select 语句的结果。
为什么第二个事务不等待 xlock 被释放?
.net ×1
angular5 ×1
asp.net ×1
asp.net-core ×1
mocking ×1
oauth-2.0 ×1
provider ×1
sql-server ×1
t-sql ×1
testbed ×1
testing ×1
transactions ×1