public void Constructor_Always_PropertiesAreGiven() { var mockChannel = new Mock <ISocketChannel>(); var uut = new ChannelCreatedNotification(mockChannel.Object); uut.Channel.ShouldBeSameAs(mockChannel.Object); }
public async Task HandleNotificationAsync_ChannelCreatedNotification_ChannelIsTextChannel_TracksChannel() { var autoMocker = new AutoMocker(); var uut = autoMocker.CreateInstance <ChannelTrackingBehavior>(); var mockChannel = new Mock <ISocketTextChannel>(); var notification = new ChannelCreatedNotification(mockChannel.Object); using (var cancellationTokenSource = new CancellationTokenSource()) { await uut.HandleNotificationAsync(notification, cancellationTokenSource.Token); autoMocker.GetMock <IChannelService>() .ShouldHaveReceived(x => x.TrackChannelAsync(mockChannel.Object, cancellationTokenSource.Token)); } }
public void HandleNotificationAsync_ChannelCreatedNotification_ChannelIsNotTextChannel_CompletesImmediately(Type channelType) { var autoMocker = new AutoMocker(); var uut = autoMocker.CreateInstance <ChannelTrackingBehavior>(); var mockChannel = typeof(Mock <>).MakeGenericType(channelType).GetConstructor(Array.Empty <Type>()).Invoke(Array.Empty <object>()) as Mock; var notification = new ChannelCreatedNotification(mockChannel.Object as ISocketChannel); using (var cancellationTokenSource = new CancellationTokenSource()) { uut.HandleNotificationAsync(notification, cancellationTokenSource.Token) .IsCompletedSuccessfully.ShouldBeTrue(); autoMocker.GetMock <IChannelService>() .Invocations.ShouldBeEmpty(); } }