public void ReturnCorrectIHubProxyProviderObject_WhenRequestedHubNameDoesNotExistInHubProxyProvidersDictionary() { // Arrange var hubConnectionProviderFactory = new Mock <IHubConnectionProviderFactory>(); var hubProxyProviderFactory = new Mock <IHubProxyProviderFactory>(); var hubConnectionProvider = new Mock <IHubConnectionProvider>(); hubConnectionProviderFactory.Setup(f => f.CreateHubConnectionProvider(It.IsAny <string>())).Returns(hubConnectionProvider.Object); var hubProxy = new Mock <IHubProxy>(); hubConnectionProvider.Setup(p => p.CreateHubProxy(It.IsAny <string>())).Returns(hubProxy.Object); var hubProxyProvider = new Mock <IHubProxyProvider>(); hubProxyProviderFactory.Setup(f => f.CreateHubProxyProvider(It.IsAny <IHubProxy>())).Returns(hubProxyProvider.Object); var unexistingIHubProxyProviderHubName = "unexisting hubName"; var signalRHubConnectionService = new MockSignalRHubConnectionService(hubConnectionProviderFactory.Object, hubProxyProviderFactory.Object); // Act var expectedHubProxyProvider = hubProxyProvider.Object; var actualHubProxyProvider = signalRHubConnectionService.GetHubProxyProvider(unexistingIHubProxyProviderHubName); // Assert Assert.That(actualHubProxyProvider, Is.SameAs(expectedHubProxyProvider)); }
public void AddANewlyCreatedIHubProxyProvider_WithCorrectKey_WhenRequestedHubNameDoesNotExistInHubProxyProvidersDictionary() { // Arrange var hubConnectionProviderFactory = new Mock <IHubConnectionProviderFactory>(); var hubProxyProviderFactory = new Mock <IHubProxyProviderFactory>(); var hubConnectionProvider = new Mock <IHubConnectionProvider>(); hubConnectionProviderFactory.Setup(f => f.CreateHubConnectionProvider(It.IsAny <string>())).Returns(hubConnectionProvider.Object); var hubProxy = new Mock <IHubProxy>(); hubConnectionProvider.Setup(p => p.CreateHubProxy(It.IsAny <string>())).Returns(hubProxy.Object); var hubProxyProvider = new Mock <IHubProxyProvider>(); hubProxyProviderFactory.Setup(f => f.CreateHubProxyProvider(It.IsAny <IHubProxy>())).Returns(hubProxyProvider.Object); var unexistingIHubProxyProviderHubName = "unexisting hubName"; var signalRHubConnectionService = new MockSignalRHubConnectionService(hubConnectionProviderFactory.Object, hubProxyProviderFactory.Object); // Act signalRHubConnectionService.GetHubProxyProvider(unexistingIHubProxyProviderHubName); var hubProxyProvidersDictionaryContainsCorrectKey = signalRHubConnectionService.HubProxyProviders.ContainsKey(unexistingIHubProxyProviderHubName); var actualHubProxyProvidersDictionaryValue = signalRHubConnectionService.HubProxyProviders[unexistingIHubProxyProviderHubName]; var expectedHubProxyProvidersDictionaryValue = hubProxyProvider.Object; // Assert Assert.That(hubProxyProvidersDictionaryContainsCorrectKey, Is.True); Assert.That(actualHubProxyProvidersDictionaryValue, Is.SameAs(expectedHubProxyProvidersDictionaryValue)); }
public void ReturnCorrectIHubProxyProviderObject_WhenRequestedHubNameAlreadyExistsInHubProxyProvidersDictionary() { // Arrange var hubConnectionProviderFactory = new Mock <IHubConnectionProviderFactory>(); var hubProxyProviderFactory = new Mock <IHubProxyProviderFactory>(); var hubConnectionProvider = new Mock <IHubConnectionProvider>(); hubConnectionProviderFactory.Setup(f => f.CreateHubConnectionProvider(It.IsAny <string>())).Returns(hubConnectionProvider.Object); var expectedIHubProxyProvider = new Mock <IHubProxyProvider>(); var existingIHubProxyProviderHubName = "existing hubName"; var signalRHubConnectionService = new MockSignalRHubConnectionService(hubConnectionProviderFactory.Object, hubProxyProviderFactory.Object); signalRHubConnectionService.HubProxyProviders.Add(existingIHubProxyProviderHubName, expectedIHubProxyProvider.Object); // Act var actualIHubProxyProvider = signalRHubConnectionService.GetHubProxyProvider(existingIHubProxyProviderHubName); // Assert Assert.That(actualIHubProxyProvider, Is.SameAs(expectedIHubProxyProvider.Object)); }