我的wcf服务配置有问题.我希望每次调用我的服务都会创建一个新的服务实例.对于并发性,我希望一次调用在另一次启动之前完成.
因此,如果我有这样的服务:
[ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Single,
InstanceContextMode=InstanceContextMode.PerCall)]
public class MyService: IMyService
{
public bool MyServiceOp()
{
Debug.WriteLine("thread "+
Thread.CurrentThread.ManagedThreadId.ToString());
Debug.WriteLine("start operation ");
Do_work()
Debug.WriteLine("end operation");
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
当我在循环中调用多个调用时,跟踪给出:
thread 1
thread 2
start operation
start operation
end operation
end operation
Run Code Online (Sandbox Code Playgroud)
虽然我想这样:
thread 1 start operation end operation
thread 2 start operation end operation
Run Code Online (Sandbox Code Playgroud)
这可能吗?谢谢
我想在自有类型上定义一对多关系.
在我的例子中,
InboundRequest:主体实体
RequestHistory:拥有类型
RequestHistoryEntry:依赖实体
public class InboundRequest : IAggregateRoot
{
public int Id { get; private set; }
public RequestHistory History { get; private set; }
}
public class RequestHistory
{
public IList<RequestHistoryEntry> HistoryEntries { get; set; }
}
public class RequestHistoryEntry
{
public RequestState State { get; private set; }
public DateTime Timestamp { get; private set; }
public int Id { get; set; }
}
builder.Entity<InboundRequest>().OwnsOne(x => x.History);
Run Code Online (Sandbox Code Playgroud)
不幸的是,EF Core给了我以下错误:
不支持从"RequestHistoryEntry"到"InboundRequest.History #RequestHistory.HistoryEntries"的关系,因为拥有的实体类型"InboundRequest.History #RequestHistory"不能在主体端.
有没有办法在自有类型和依赖项列表之间建立一对多的关系?
我想重置虚假呼叫历史记录或忽略呼叫.
在测试类构造函数的Init方法中调用伪断言方法,我想忽略此调用,因为它不是测试操作的一部分.
这是一个例子:
[TestClass]
public class UnitTest1
{
private MyFakedClass myFakedObject;
private SUT sut;
[TestInitialize]
public void Init()
{
myFakedObject = A.Fake<MyFakedClass>();
sut = new SUT(myFakedObject); //constructor calls myFakedObject.AssertedMethod()
}
[TestMethod]
public void TestMethod1()
{
sut.TestedMethod(); //TestedMethod calls myFakedObject.AssertedMethod() again...
A.CallTo(() => myFakedObject.AssertedMethod()).MustHaveHappened(Repeated.Exactly.Once);
//...So this is false
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 ASP.Net Core 2.2。
默认情况下,会话 cookie 存储在以.AspNetCore.Session特定域命名的 cookie 中(例如:)mydomain.com。
就我而言,我在域下有多个 .net 核心应用程序。 mydomain.com/Module1, mydomain.com/Module2, 等等...
在这种情况下,所有应用程序为其会话共享相同的 cookie。结果是应用程序尝试读取另一个会话并在日志中生成警告:
取消保护会话 cookie 时出错。System.Security.Cryptography.CryptographicException:在密钥环中找不到密钥 {...}。
尽管这只是一个警告并且会话似乎在每个应用程序上都运行良好,但我想知道处理这种情况的正确方法。
谢谢。
c# ×3
asp.net ×1
asp.net-core ×1
cookies ×1
fakeiteasy ×1
mocking ×1
session ×1
unit-testing ×1
wcf ×1