Here are the examples of the csharp api Moq.Mock.Verify() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1587 Examples
19
Source : AppViewModelTests.cs
with Microsoft Public License
from achimismaili
with Microsoft Public License
from achimismaili
[Fact]
public void Test_SubscribedToEventAggregator()
{
_eventAggregator.Verify(x => x.Subscribe(_mainVM));
}
19
Source : DependencyScopeExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public void GetLogger_ReturnsDependencyInstance_IfRegistered()
{
// Arrange
Mock<ILogger> instanceMock = new Mock<ILogger>();
_resolverMock.Setup(r => r.GetService(typeof(ILogger)))
.Returns(instanceMock.Object)
.Verifiable();
// Act
ILogger actual = _resolverMock.Object.GetLogger();
// replacedert
replacedert.Same(instanceMock.Object, actual);
instanceMock.Verify();
}
19
Source : DependencyScopeExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public void GetSettings_ReturnsDependencyInstance_IfRegistered()
{
// Arrange
SettingsDictionary instance = new SettingsDictionary();
instance["key"] = "value";
_resolverMock.Setup(r => r.GetService(typeof(SettingsDictionary)))
.Returns(instance)
.Verifiable();
// Act
SettingsDictionary actual = _resolverMock.Object.GetSettings();
// replacedert
replacedert.Same(instance, actual);
_resolverMock.Verify();
}
19
Source : DependencyScopeExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public void GetSettings_ReturnsDefaultInstance_IfEmptyDictionaryRegistered()
{
// Arrange
SettingsDictionary instance = new SettingsDictionary();
instance.Clear();
_resolverMock.Setup(r => r.GetService(typeof(SettingsDictionary)))
.Returns(instance)
.Verifiable();
// Act
SettingsDictionary actual = _resolverMock.Object.GetSettings();
// replacedert
replacedert.NotSame(instance, actual);
_resolverMock.Verify();
}
19
Source : DependencyScopeExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public void GetService_ReturnsService()
{
_resolverMock.Setup<object>(r => r.GetService(typeof(Service)))
.Returns(_service1)
.Verifiable();
Service actual = _resolver.GetService<Service>();
_resolverMock.Verify();
replacedert.Same(_service1, actual);
}
19
Source : WebHookRegistrationsControllerTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task Get_Returns_WebHooks()
{
// Arrange
IEnumerable<WebHook> hooks = CreateWebHooks();
_regsMock.Setup(r => r.GetWebHooksAsync(_principal, It.IsAny<Func<string, WebHook, Task>>()))
.ReturnsAsync(hooks)
.Verifiable();
// Act
var actual = await _controller.Get();
// replacedert
_regsMock.Verify();
replacedert.Equal(WebHookCount, actual.Count());
}
19
Source : WebHookRegistrationsControllerTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task Get_Returns_EmptyList()
{
// Arrange
_regsMock.Setup(r => r.GetWebHooksAsync(_principal, It.IsAny<Func<string, WebHook, Task>>()))
.ReturnsAsync(new WebHook[0])
.Verifiable();
// Act
var actual = await _controller.Get();
// replacedert
_regsMock.Verify();
replacedert.Empty(actual);
}
19
Source : WebHookRegistrationsControllerTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task AddPrivateFilters_Calls_RegistrarWithNoFilter()
{
// Arrange
var webHook = new WebHook();
_registrarMock.Setup(r => r.RegisterAsync(_controllerContext.Request, webHook))
.Returns(Task.FromResult(true))
.Verifiable();
// Act
await _controller.AddPrivateFilters("12345", webHook);
// replacedert
_registrarMock.Verify();
}
19
Source : WebHookRegistrationsControllerTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task AddPrivateFilters_Calls_RegistrarWithFilter()
{
// Arrange
var webHook = new WebHook();
webHook.Filters.Add(FilterName);
_registrarMock.Setup(r => r.RegisterAsync(_controllerContext.Request, webHook))
.Returns(Task.FromResult(true))
.Verifiable();
// Act
await _controller.AddPrivateFilters("12345", webHook);
// replacedert
_registrarMock.Verify();
}
19
Source : DependencyScopeExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public void GetIdValidator_ReturnsDependencyInstance_IfRegistered()
{
// Arrange
Mock<IWebHookIdValidator> instanceMock = new Mock<IWebHookIdValidator>();
_resolverMock.Setup(r => r.GetService(typeof(IWebHookIdValidator)))
.Returns(instanceMock.Object)
.Verifiable();
// Act
IWebHookIdValidator actual = _resolverMock.Object.GetIdValidator();
// replacedert
replacedert.Same(instanceMock.Object, actual);
instanceMock.Verify();
}
19
Source : DependencyScopeExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public void GetRegistrars_ReturnsDependencyInstances_IfRegistered()
{
// Arrange
Mock<IWebHookRegistrar> instanceMock = new Mock<IWebHookRegistrar>();
List<IWebHookRegistrar> instances = new List<IWebHookRegistrar> { instanceMock.Object };
_resolverMock.Setup(r => r.GetServices(typeof(IWebHookRegistrar)))
.Returns(instances)
.Verifiable();
// Act
IEnumerable<IWebHookRegistrar> actual = _resolverMock.Object.GetRegistrars();
// replacedert
replacedert.Same(instances, actual);
instanceMock.Verify();
}
19
Source : AzureWebHookDequeueManagerTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Theory]
[MemberData(nameof(DequeueData))]
public async Task DequeueAndSendWebHooks_GetsMessagesAndSubmitsToSender(int[] data)
{
// Arrange
var index = 0;
_storageMock.Setup(s => s.GetMessagesAsync(StorageManagerMock.CloudQueue, AzureWebHookDequeueManager.MaxDequeuedMessages, _messageTimeout))
.Returns(() =>
{
var count = index > data.Length ? 0 : data[index++];
if (count < 0)
{
throw new Exception("Catch this!");
}
var result = StorageManagerMock.CreateQueueMessages(count);
return Task.FromResult(result);
})
.Callback(() =>
{
if (index > data.Length)
{
_tokenSource.Cancel();
}
})
.Verifiable();
_dequeueManager = new AzureWebHookDequeueManagerMock(this, storageManager: _storageMock.Object, sender: _senderMock.Object);
// Act
await _dequeueManager.DequeueAndSendWebHooks(_tokenSource.Token);
// replacedert
var expected = data.Where(i => i > 0).Count();
_senderMock.Verify(s => s.SendWebHookWorkItemsAsync(It.IsAny<IEnumerable<WebHookWorkItem>>()), Times.Exactly(expected));
}
19
Source : AzureWebHookDequeueManagerTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Theory]
[MemberData(nameof(SenderData))]
public async Task QueuedSender_Deletes_AllCompletedResponses(int[] statusCodes)
{
// Arrange
_handlerMock.Handler = (req, index) =>
{
if (statusCodes[index] < 0)
{
throw new Exception("Catch this!");
}
var response = req.CreateResponse((HttpStatusCode)statusCodes[index]);
return Task.FromResult(response);
};
var client = new HttpClient(_handlerMock);
_dequeueManager = new AzureWebHookDequeueManagerMock(this, storageManager: _storageMock.Object, httpClient: client);
var workItems = StorageManagerMock.CreateWorkItems(statusCodes.Length);
// Act
await _dequeueManager.WebHookSender.SendWebHookWorkItemsAsync(workItems);
// replacedert
_storageMock.Verify(s => s.DeleteMessagesAsync(StorageManagerMock.CloudQueue, It.Is<IEnumerable<CloudQueueMessage>>(m => m.Count() == statusCodes.Length)), Times.Once());
}
19
Source : AzureWebHookDequeueManagerTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Theory]
[MemberData(nameof(SenderData))]
public async Task QueuedSender_Deletes_SuccessAndGoneResponses(int[] statusCodes)
{
// Arrange
_handlerMock.Handler = (req, index) =>
{
if (statusCodes[index] < 0)
{
throw new Exception("Catch this!");
}
var response = req.CreateResponse((HttpStatusCode)statusCodes[index]);
return Task.FromResult(response);
};
var client = new HttpClient(_handlerMock);
_dequeueManager = new AzureWebHookDequeueManagerMock(this, maxAttempts: 1, storageManager: _storageMock.Object, httpClient: client);
var workItems = StorageManagerMock.CreateWorkItems(statusCodes.Length);
// Act
await _dequeueManager.WebHookSender.SendWebHookWorkItemsAsync(workItems);
// replacedert
var expected = statusCodes.Where(i => (i >= 200 && i <= 299) || i == 410).Count();
_storageMock.Verify(s => s.DeleteMessagesAsync(StorageManagerMock.CloudQueue, It.Is<IEnumerable<CloudQueueMessage>>(m => m.Count() == expected)), Times.Once());
}
19
Source : AzureWebHookSenderTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task SendWebHookWorkItems_SendsMessages()
{
// Arrange
IEnumerable<WebHookWorkItem> workItems = StorageManagerMock.CreateWorkItems(32);
// Act
await _sender.SendWebHookWorkItemsAsync(workItems);
// replacedert
_storageMock.Verify(s => s.AddMessagesAsync(StorageManagerMock.CloudQueue, It.Is<IEnumerable<CloudQueueMessage>>(m => m.Count() == 32)));
_storageMock.Verify();
}
19
Source : AzureWebHookSenderTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task SendWebHookWorkItems_SendsMessages()
{
// Arrange
IEnumerable<WebHookWorkItem> workItems = StorageManagerMock.CreateWorkItems(32);
// Act
await _sender.SendWebHookWorkItemsAsync(workItems);
// replacedert
_storageMock.Verify(s => s.AddMessagesAsync(StorageManagerMock.CloudQueue, It.Is<IEnumerable<CloudQueueMessage>>(m => m.Count() == 32)));
_storageMock.Verify();
}
19
Source : DependencyResolverExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public void GetFilterManager_ReturnsDependencyInstance_IfRegistered()
{
// Arrange
Mock<IWebHookFilterManager> instanceMock = new Mock<IWebHookFilterManager>();
_resolverMock.Setup(r => r.GetService(typeof(IWebHookFilterManager)))
.Returns(instanceMock.Object)
.Verifiable();
// Act
IWebHookFilterManager actual = _resolverMock.Object.GetFilterManager();
// replacedert
replacedert.Same(instanceMock.Object, actual);
instanceMock.Verify();
}
19
Source : DependencyResolverExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public void GetSender_ReturnsDependencyInstance_IfRegistered()
{
// Arrange
Mock<IWebHookSender> instanceMock = new Mock<IWebHookSender>();
_resolverMock.Setup(r => r.GetService(typeof(IWebHookSender)))
.Returns(instanceMock.Object)
.Verifiable();
// Act
IWebHookSender actual = _resolverMock.Object.GetSender();
// replacedert
replacedert.Same(instanceMock.Object, actual);
instanceMock.Verify();
}
19
Source : DependencyResolverExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public void GetManager_ReturnsDependencyInstance_IfRegistered()
{
// Arrange
Mock<IWebHookManager> instanceMock = new Mock<IWebHookManager>();
_resolverMock.Setup(r => r.GetService(typeof(IWebHookManager)))
.Returns(instanceMock.Object)
.Verifiable();
// Act
IWebHookManager actual = _resolverMock.Object.GetManager();
// replacedert
replacedert.Same(instanceMock.Object, actual);
instanceMock.Verify();
}
19
Source : DependencyResolverExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public void GetStore_ReturnsDependencyInstance_IfRegistered()
{
// Arrange
Mock<IWebHookStore> instanceMock = new Mock<IWebHookStore>();
_resolverMock.Setup(r => r.GetService(typeof(IWebHookStore)))
.Returns(instanceMock.Object)
.Verifiable();
// Act
IWebHookStore actual = _resolverMock.Object.GetStore();
// replacedert
replacedert.Same(instanceMock.Object, actual);
instanceMock.Verify();
}
19
Source : DependencyResolverExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public void GetUser_ReturnsDependencyInstance_IfRegistered()
{
// Arrange
Mock<IWebHookUser> instanceMock = new Mock<IWebHookUser>();
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(instanceMock.Object)
.Verifiable();
// Act
IWebHookUser actual = _resolverMock.Object.GetUser();
// replacedert
replacedert.Same(instanceMock.Object, actual);
instanceMock.Verify();
}
19
Source : DependencyResolverExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public void GetFilterProviders_ReturnsDependencyInstances_IfRegistered()
{
// Arrange
Mock<IWebHookFilterProvider> instanceMock = new Mock<IWebHookFilterProvider>();
List<IWebHookFilterProvider> instances = new List<IWebHookFilterProvider> { instanceMock.Object };
_resolverMock.Setup(r => r.GetServices(typeof(IWebHookFilterProvider)))
.Returns(instances)
.Verifiable();
// Act
IEnumerable<IWebHookFilterProvider> actual = _resolverMock.Object.GetFilterProviders();
// replacedert
replacedert.Same(instances, actual);
instanceMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesNullData()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", data: null);
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesNullData()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", data: null);
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesNullDataAndNullPredicate()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", data: null, predicate: null);
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesNullDataAndNullPredicate()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", data: null, predicate: null);
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesEmptyDictionaryData()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", new Dictionary<string, object>());
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesEmptyDictionaryData()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", new Dictionary<string, object>());
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesEmptyDictionaryDataAndNoPredicate()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", new Dictionary<string, object>());
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesEmptyDictionaryDataAndNoPredicate()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", new Dictionary<string, object>());
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesEmptyObjectData()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", new object());
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesEmptyObjectData()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", new object());
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesEmptyObjectDataAndNoPredicate()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", new object(), predicate: null);
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesEmptyObjectDataAndNoPredicate()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", new object(), predicate: null);
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesNonemptyDictionaryData()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", new Dictionary<string, object>() { { "d1", "v1" } });
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1" && (string)n.Single()["d1"] == "v1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesNonemptyDictionaryData()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", new Dictionary<string, object>() { { "d1", "v1" } });
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1" && (string)n.Single()["d1"] == "v1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesNonemptyDictionaryDataAndPredicate()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
Func<WebHook, string, bool> predicate = (w, s) => true;
// Act
await _controller.NotifyAsync("a1", new Dictionary<string, object>() { { "d1", "v1" } }, predicate);
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1" && (string)n.Single()["d1"] == "v1"), predicate));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesNonemptyDictionaryDataAndPredicate()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
Func<WebHook, string, bool> predicate = (w, s) => true;
// Act
await _controller.NotifyAsync("a1", new Dictionary<string, object>() { { "d1", "v1" } }, predicate);
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1" && (string)n.Single()["d1"] == "v1"), predicate));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesNonemptyObjectData()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", new { d1 = "v1" });
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1" && (string)n.Single()["d1"] == "v1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesNonemptyObjectData()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
// Act
await _controller.NotifyAsync("a1", new { d1 = "v1" });
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1" && (string)n.Single()["d1"] == "v1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesNonemptyObjectDataAndPredicate()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
Func<WebHook, string, bool> predicate = (w, s) => true;
// Act
await _controller.NotifyAsync("a1", new { d1 = "v1" }, predicate);
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1" && (string)n.Single()["d1"] == "v1"), predicate));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAsync_HandlesNonemptyObjectDataAndPredicate()
{
// Arrange
_resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
.Returns(_user)
.Verifiable();
Func<WebHook, string, bool> predicate = (w, s) => true;
// Act
await _controller.NotifyAsync("a1", new { d1 = "v1" }, predicate);
// replacedert
_managerMock.Verify(m => m.NotifyAsync("TestUser", It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1" && (string)n.Single()["d1"] == "v1"), predicate));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAllAsync_HandlesNullData()
{
// Act
await _controller.NotifyAllAsync("a1", data: null);
// replacedert
_managerMock.Verify(m => m.NotifyAllAsync(It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAllAsync_HandlesNullData()
{
// Act
await _controller.NotifyAllAsync("a1", data: null);
// replacedert
_managerMock.Verify(m => m.NotifyAllAsync(It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAllAsync_HandlesNullDataAndNullPredicate()
{
// Act
await _controller.NotifyAllAsync("a1", data: null, predicate: null);
// replacedert
_managerMock.Verify(m => m.NotifyAllAsync(It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAllAsync_HandlesNullDataAndNullPredicate()
{
// Act
await _controller.NotifyAllAsync("a1", data: null, predicate: null);
// replacedert
_managerMock.Verify(m => m.NotifyAllAsync(It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAllAsync_HandlesEmptyDictionaryData()
{
// Act
await _controller.NotifyAllAsync("a1", new Dictionary<string, object>());
// replacedert
_managerMock.Verify(m => m.NotifyAllAsync(It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAllAsync_HandlesEmptyDictionaryData()
{
// Act
await _controller.NotifyAllAsync("a1", new Dictionary<string, object>());
// replacedert
_managerMock.Verify(m => m.NotifyAllAsync(It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAllAsync_HandlesEmptyDictionaryDataAndNoPredicate()
{
// Act
await _controller.NotifyAllAsync("a1", new Dictionary<string, object>());
// replacedert
_managerMock.Verify(m => m.NotifyAllAsync(It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
19
Source : ApiControllerExtensionsTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task NotifyAllAsync_HandlesEmptyDictionaryDataAndNoPredicate()
{
// Act
await _controller.NotifyAllAsync("a1", new Dictionary<string, object>());
// replacedert
_managerMock.Verify(m => m.NotifyAllAsync(It.Is<IEnumerable<NotificationDictionary>>(n => n.Single().Action == "a1"), null));
_resolverMock.Verify();
}
See More Examples