本文整理汇总了C#中Mocks类的典型用法代码示例。如果您正苦于以下问题:C# Mocks类的具体用法?C# Mocks怎么用?C# Mocks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mocks类属于命名空间,在下文中一共展示了Mocks类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SendMessageAsync
private async Task SendMessageAsync(Mocks.CloudBlobStorageProviderMock cloudStorage, Mocks.InboxHttpHandlerMock inboxMock, CryptoSettings senderCrypto, OwnEndpoint senderEndpoint, Endpoint receiverEndpoint)
{
Requires.NotNull(cloudStorage, "cloudStorage");
Requires.NotNull(senderCrypto, "senderCrypto");
Requires.NotNull(senderEndpoint, "senderEndpoint");
Requires.NotNull(receiverEndpoint, "receiverEndpoint");
var httpHandler = new Mocks.HttpMessageHandlerMock();
cloudStorage.AddHttpHandler(httpHandler);
inboxMock.Register(httpHandler);
var sentMessage = Valid.Message;
var channel = new Channel()
{
HttpClient = new HttpClient(httpHandler),
CloudBlobStorage = cloudStorage,
CryptoServices = senderCrypto,
Endpoint = senderEndpoint,
Logger = this.logger,
};
await channel.PostAsync(sentMessage, new[] { receiverEndpoint }, Valid.ExpirationUtc);
}
开发者ID:AArnott,项目名称:IronPigeon,代码行数:26,代码来源:InteropTests.cs
示例2: ReceiveMessageAsync
private async Task ReceiveMessageAsync(Mocks.CloudBlobStorageProviderMock cloudStorage, Mocks.InboxHttpHandlerMock inboxMock, CryptoSettings receiverCrypto, OwnEndpoint receiverEndpoint)
{
Requires.NotNull(cloudStorage, "cloudStorage");
Requires.NotNull(receiverCrypto, "receiverCrypto");
Requires.NotNull(receiverEndpoint, "receiverEndpoint");
var httpHandler = new Mocks.HttpMessageHandlerMock();
cloudStorage.AddHttpHandler(httpHandler);
inboxMock.Register(httpHandler);
var channel = new Channel
{
HttpClient = new HttpClient(httpHandler),
HttpClientLongPoll = new HttpClient(httpHandler),
CloudBlobStorage = cloudStorage,
CryptoServices = receiverCrypto,
Endpoint = receiverEndpoint,
Logger = this.logger,
};
var messages = await channel.ReceiveAsync();
Assert.Equal(1, messages.Count);
Assert.Equal(Valid.Message, messages[0].Payload);
}
开发者ID:AArnott,项目名称:IronPigeon,代码行数:25,代码来源:InteropTests.cs
示例3: TestGoodDataAsync
private async Task TestGoodDataAsync(string[] messageData, string expectedData, bool eightBitClean)
{
Mocks mocks = new Mocks();
if (eightBitClean)
{
mocks.Connection.SetupGet(c => c.ReaderEncoding).Returns(Encoding.UTF8);
}
MemoryMessage.Builder messageBuilder = new MemoryMessage.Builder();
mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);
mocks.ServerBehaviour.Setup(b => b.GetMaximumMessageSize(It.IsAny<IConnection>())).Returns((long?)null);
int messageLine = 0;
mocks.Connection.Setup(c => c.ReadLineAsync()).Returns(() => Task.FromResult(messageData[messageLine++]));
DataVerb verb = new DataVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("DATA"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.StartMailInputEndWithDot);
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
using (StreamReader dataReader = new StreamReader(messageBuilder.GetData(), eightBitClean ? Encoding.UTF8 : new ASCIISevenBitTruncatingEncoding()))
{
Assert.Equal(expectedData, dataReader.ReadToEnd());
}
}
开发者ID:rnwood,项目名称:smtp4dev,代码行数:27,代码来源:DataVerbTests.cs
示例4: ForceBuild_when_using_weburl_should_call_api_with_parameters
public void ForceBuild_when_using_weburl_should_call_api_with_parameters()
{
Mocks mocks = new Mocks();
SetupDefaultMockState(mocks);
var target = CreateTestTarget(mocks);
target.WebURL = new Uri(@"http://test");
target.Initialize(new BuildServer(), "TestProjectName", new Settings());
Dictionary<string, string> parameters = new Dictionary<string, string>()
{
{"SomeParameter", "SomeValue"}
};
string userName = "TestUser";
// Act
target.ForceBuild("", parameters, userName);
// Assert
mocks.MockJenkinsApi
.Verify(x => x.ForceBuild(It.IsAny<Uri>(),
parameters),
Times.Once);
}
开发者ID:nrjohnstone,项目名称:cctray-jenkins-transport,代码行数:27,代码来源:JenkinsProjectManagerTests.cs
示例5: BlogCategory
public void BlogCategory()
{
var category = new CategoryModel { Id = 1, Title = "Test Category", Slug = "test-category" };
var mocks = new Mocks();
Assert.AreEqual("/blog/category/test-category", BlogUrlHelperExtensions.BlogCategory(mocks.UrlHelper, category, 1));
Assert.AreEqual("/blog/category/test-category/page-2", BlogUrlHelperExtensions.BlogCategory(mocks.UrlHelper, category, 2));
}
开发者ID:xb11,项目名称:Website,代码行数:7,代码来源:BlogUrlHelperExtensionsTests.cs
示例6: Process_RecordsClientName
public async Task Process_RecordsClientName()
{
Mocks mocks = new Mocks();
EhloVerb ehloVerb = new EhloVerb();
await ehloVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("EHLO foobar"));
mocks.Session.VerifySet(s => s.ClientName = "foobar");
}
开发者ID:rnwood,项目名称:smtp4dev,代码行数:8,代码来源:EhloVerbTests.cs
示例7: ShouldProperlyInitializeMembers
public void ShouldProperlyInitializeMembers()
{
var mocks = new Mocks();
var repl = GetRepl(mocks);
repl.FileSystem.ShouldEqual(mocks.FileSystem.Object);
repl.ScriptEngine.ShouldEqual(mocks.ScriptEngine.Object);
repl.Console.ShouldEqual(mocks.Console.Object);
}
开发者ID:AsCloud,项目名称:scriptcs,代码行数:8,代码来源:ReplTests.cs
示例8: ExecuteWithLargerStackIfRequiredWithNoNewThread
public void ExecuteWithLargerStackIfRequiredWithNoNewThread()
{
var mocks = new Mocks();
var environment = mocks.CreateReactEnvironment();
environment.ExecuteWithLargerStackIfRequired<int>("1+1");
mocks.Engine.Verify(x => x.Evaluate<int>("1+1"));
}
开发者ID:prabirshrestha,项目名称:React.NET,代码行数:8,代码来源:ReactEnvironmentTest.cs
示例9: ExecuteWithLargerStackIfRequiredWithNoNewThread
public void ExecuteWithLargerStackIfRequiredWithNoNewThread()
{
var mocks = new Mocks();
var environment = mocks.CreateReactEnvironment();
environment.ExecuteWithLargerStackIfRequired<int>("foo");
mocks.Engine.Verify(x => x.CallFunction<int>("foo"), Times.Exactly(1));
}
开发者ID:jjridge7,项目名称:React.NET,代码行数:8,代码来源:ReactEnvironmentTest.cs
示例10: ShouldNotTransformJsxIfNoAnnotationPresent
public void ShouldNotTransformJsxIfNoAnnotationPresent()
{
var mocks = new Mocks();
var environment = mocks.CreateReactEnvironment();
var input = "<div>Hello World</div>";
var output = environment.TransformJsx(input);
Assert.Equal(input, output);
}
开发者ID:prabirshrestha,项目名称:React.NET,代码行数:9,代码来源:ReactEnvironmentTest.cs
示例11: Init
public void Init()
{
_left = new AGSEdge { Value = 100 };
_right = new AGSEdge { Value = 200 };
_top = new AGSEdge { Value = 200 };
_bottom = new AGSEdge { Value = 100 };
_edges = new AGSEdges (_left, _right, _top, _bottom);
_mocks = Mocks.Init();
}
开发者ID:tzachshabtay,项目名称:MonoAGS,代码行数:9,代码来源:EdgesTests.cs
示例12: Process_NoArguments_Accepted
public async Task Process_NoArguments_Accepted()
{
Mocks mocks = new Mocks();
EhloVerb ehloVerb = new EhloVerb();
await ehloVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("EHLO"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
mocks.Session.VerifySet(s => s.ClientName = "");
}
开发者ID:rnwood,项目名称:smtp4dev,代码行数:9,代码来源:EhloVerbTests.cs
示例13: Noop
public async Task Noop()
{
Mocks mocks = new Mocks();
NoopVerb verb = new NoopVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("NOOP"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
}
开发者ID:rnwood,项目名称:smtp4dev,代码行数:9,代码来源:NoopVerbTests.cs
示例14: Quit_RespondsWithClosingChannel
public async Task Quit_RespondsWithClosingChannel()
{
Mocks mocks = new Mocks();
QuitVerb quitVerb = new QuitVerb();
await quitVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("QUIT"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.ClosingTransmissionChannel);
}
开发者ID:rnwood,项目名称:smtp4dev,代码行数:9,代码来源:QuitVerbTests.cs
示例15: Noop
public void Noop()
{
Mocks mocks = new Mocks();
NoopVerb verb = new NoopVerb();
verb.Process(mocks.Connection.Object, new SmtpCommand("NOOP"));
mocks.VerifyWriteResponse(StandardSmtpResponseCode.OK);
}
开发者ID:LiDamon,项目名称:smtp4dev,代码行数:9,代码来源:NoopVerbTests.cs
示例16: TheInitializeMethod
public TheInitializeMethod()
{
_tempPath = Path.GetTempPath();
_mocks = new Mocks();
_repl = GetRepl(_mocks);
_mocks.FileSystem.Setup(x => x.CurrentDirectory).Returns(_tempPath);
var paths = new[] { Path.Combine(_tempPath, "path" ) };
_repl.Initialize(paths, new[] { _mocks.ScriptPack.Object });
}
开发者ID:selony,项目名称:scriptcs,代码行数:10,代码来源:ReplTests.cs
示例17: ProcessAsync_UnregisteredSubCommand_ErrorResponse
public async Task ProcessAsync_UnregisteredSubCommand_ErrorResponse()
{
Mocks mocks = new Mocks();
Mock<VerbWithSubCommands> verbWithSubCommands = new Mock<VerbWithSubCommands>() { CallBase = true };
await verbWithSubCommands.Object.ProcessAsync(mocks.Connection.Object, new SmtpCommand("VERB SUBCOMMAND1"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.CommandParameterNotImplemented);
}
开发者ID:rnwood,项目名称:smtp4dev,代码行数:10,代码来源:VerbWithSubCommandsTests.cs
示例18: SayHeloTwice_ReturnsError
public async Task SayHeloTwice_ReturnsError()
{
Mocks mocks = new Mocks();
mocks.Session.SetupGet(s => s.ClientName).Returns("already.said.helo");
HeloVerb verb = new HeloVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("HELO foo.blah"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.BadSequenceOfCommands);
}
开发者ID:rnwood,项目名称:smtp4dev,代码行数:10,代码来源:HeloVerbTests.cs
示例19: SayHelo
public async Task SayHelo()
{
Mocks mocks = new Mocks();
HeloVerb verb = new HeloVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("HELO foo.blah"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
mocks.Session.VerifySet(s => s.ClientName = "foo.blah");
}
开发者ID:rnwood,项目名称:smtp4dev,代码行数:10,代码来源:HeloVerbTests.cs
示例20: ProcessAsync
public async Task ProcessAsync()
{
Mocks mocks = new Mocks();
RsetVerb verb = new RsetVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("RSET"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
mocks.Connection.Verify(c => c.AbortMessage());
}
开发者ID:rnwood,项目名称:smtp4dev,代码行数:10,代码来源:RsetVerbTests.cs
注:本文中的Mocks类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论