本文整理汇总了C#中Mocks类的典型用法代码示例。如果您正苦于以下问题:C# Mocks类的具体用法?C# Mocks怎么用?C# Mocks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mocks类属于命名空间,在下文中一共展示了Mocks类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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());
}
}
示例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);
}
示例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));
}
示例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");
}
示例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);
}
示例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"));
}
示例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));
}
示例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);
}
示例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();
}
示例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 = "");
}
示例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);
}
示例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);
}
示例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);
}