public void CreateValidInstance_WhenParametersAreCorrect() { // Arrange var commandUtilizationUpdateStrategy = new Mock <ICommandUtilizationUpdateStrategy>(); var signalRHubConnectionService = new Mock <ISignalRHubConnectionService>(); var commandJsonConvertProvider = new Mock <ICommandJsonConvertProvider>(); var remoteUserProvider = new Mock <IRemoteUserProvider>(); var hubProxyProvider = new Mock <IHubProxyProvider>(); signalRHubConnectionService.Setup(s => s.GetHubProxyProvider(It.IsAny <string>())).Returns(hubProxyProvider.Object); // Act var signalRCommandUtilizationStrategy = new SignalRCommandUtilizationStrategy(commandUtilizationUpdateStrategy.Object, signalRHubConnectionService.Object, commandJsonConvertProvider.Object, remoteUserProvider.Object); // Assert Assert.That(signalRCommandUtilizationStrategy, Is.Not.Null.And.InstanceOf <ICommandUtilizationStrategy>()); }
public void InvokeIHubProxyProvider_OnMethod_WithCorrectHubMethodNameParameter() { // Arrange var commandUtilizationUpdateStrategy = new Mock <ICommandUtilizationUpdateStrategy>(); var signalRHubConnectionService = new Mock <ISignalRHubConnectionService>(); var commandJsonConvertProvider = new Mock <ICommandJsonConvertProvider>(); var remoteUserProvider = new Mock <IRemoteUserProvider>(); var hubProxyProvider = new Mock <IHubProxyProvider>(); signalRHubConnectionService.Setup(s => s.GetHubProxyProvider(It.IsAny <string>())).Returns(hubProxyProvider.Object); var expectedHubMethodName = "UpdateParsingSessionId"; // Act var signalRCommandUtilizationStrategy = new SignalRCommandUtilizationStrategy(commandUtilizationUpdateStrategy.Object, signalRHubConnectionService.Object, commandJsonConvertProvider.Object, remoteUserProvider.Object); // Assert hubProxyProvider.Verify(p => p.On <string>(expectedHubMethodName, It.IsAny <Action <string> >()), Times.Once); }
public void InvokeISignalRHubConnectionService_GetHubProxyProviderMethod_WithCorrectParameter() { // Arrange var commandUtilizationUpdateStrategy = new Mock <ICommandUtilizationUpdateStrategy>(); var signalRHubConnectionService = new Mock <ISignalRHubConnectionService>(); var commandJsonConvertProvider = new Mock <ICommandJsonConvertProvider>(); var remoteUserProvider = new Mock <IRemoteUserProvider>(); var hubProxyProvider = new Mock <IHubProxyProvider>(); signalRHubConnectionService.Setup(s => s.GetHubProxyProvider(It.IsAny <string>())).Returns(hubProxyProvider.Object); var expectedHubName = "LogFileParserHub"; // Act var signalRCommandUtilizationStrategy = new SignalRCommandUtilizationStrategy(commandUtilizationUpdateStrategy.Object, signalRHubConnectionService.Object, commandJsonConvertProvider.Object, remoteUserProvider.Object); // Assert signalRHubConnectionService.Verify(s => s.GetHubProxyProvider(expectedHubName), Times.Once); }
public void ThrowArgumentNullException_WhenICommandParameterIsNull() { // Arrange var commandUtilizationUpdateStrategy = new Mock <ICommandUtilizationUpdateStrategy>(); var signalRHubConnectionService = new Mock <ISignalRHubConnectionService>(); var commandJsonConvertProvider = new Mock <ICommandJsonConvertProvider>(); var remoteUserProvider = new Mock <IRemoteUserProvider>(); var hubProxyProvider = new Mock <IHubProxyProvider>(); signalRHubConnectionService.Setup(s => s.GetHubProxyProvider(It.IsAny <string>())).Returns(hubProxyProvider.Object); var signalRCommandUtilizationStrategy = new SignalRCommandUtilizationStrategy(commandUtilizationUpdateStrategy.Object, signalRHubConnectionService.Object, commandJsonConvertProvider.Object, remoteUserProvider.Object); ICommand invalidCommand = null; // Act & Assert Assert.That( () => signalRCommandUtilizationStrategy.UtilizeCommand(invalidCommand), Throws.InstanceOf <ArgumentNullException>().With.Message.Contains(nameof(ICommand))); }