private IEnumerable <Connection> MergeIntoConnections( IEnumerable <Capability> capabilities, IEnumerable <ChannelDto> channelDtos ) { var connections = new List <Connection>(); foreach (var channelDto in channelDtos) { var relevantCapability = capabilities.Where(c => c.SlackChannelId == channelDto.Id); connections.AddRange( relevantCapability.Select(capability => new Connection( new ClientTypeCapability(), new ClientName(capability.Name), new ClientId(capability.Id.ToString()), new ChannelTypeSlack(), ChannelName.Create(channelDto.Name), new ChannelId(capability.SlackChannelId) ) ) ); } return(connections); }
public void FixChannelNameForSlack_NumbersAndCharsDashSeparated_ReturnsValidSlackChannelName() { // Arrange var channelName = "123Numbers-456MoreNumbers"; // Act var fixedChannelName = ChannelName.Create(channelName); // Assert AssertValidSlackChannelName(fixedChannelName); }
public void FixChannelNameForSlack_DashSeparated_ReturnsValidSlackChannelName() { // Arrange var channelName = "dash-separated"; // Act var fixedChannelName = ChannelName.Create(channelName); // Assert AssertValidSlackChannelName(fixedChannelName); }
public void FixChannelNameForSlack_CharAndNumbers_ReturnsValidSlackChannelName() { // Arrange var channelName = "Numbers123"; // Act var fixedChannelName = ChannelName.Create(channelName); // Assert AssertValidSlackChannelName(fixedChannelName); }
public void FixChannelNameForSlack_NumbersAndLowerCaseUnderscoreSeparated_ReturnsValidSlackChannelName() { // Arrange var channelName = "123numbers_456moreNumbers"; // Act var fixedChannelName = ChannelName.Create(channelName); // Assert AssertValidSlackChannelName(fixedChannelName); }
public void FixChannelNameForSlack_LowerCasing_ReturnsValidSlackChannelName() { // Arrange var channelName = "lowercase"; // Act var fixedChannelName = ChannelName.Create(channelName); // Assert AssertValidSlackChannelName(fixedChannelName); }
public void FixChannelNameForSlack_NameWithMultipleUpperCaseLetters_ReturnsValidSlackChannelName() { // Arrange var channelName = "TestNoDoubleNSCreation"; // Act var fixedChannelName = ChannelName.Create(channelName); // Assert AssertValidSlackChannelName(fixedChannelName); }
public void FixChannelNameForSlack_LowerCaseAndNumbersDashSeparated_ReturnsValidSlackChannelName() { // Arrange var channelName = "numbers123-moreNumbers456"; // Act var fixedChannelName = ChannelName.Create(channelName); // Assert AssertValidSlackChannelName(fixedChannelName); }
public async Task HandleAsync(RenameChannelCommand command) { var group = await _groupRepository.GetAsync(GroupId.From(command.GroupId)) ?? throw new GroupNotFoundException(GroupId.From(command.GroupId)); var channel = await _channelRepository.GetAsync(group.Id, ChannelId.From(command.ChannelId)) ?? throw new ChannelNotFoundException(ChannelId.From(command.ChannelId)); var name = ChannelName.Create(command.Name); group.RenameChannel(UserId.From(command.UserId), channel, name); }
public void FixChannelNameForSlack_NameWithLength100_ReturnsValidSlackChannelName() { // Arrange var channelNameOfLength100 = string.Join("", Enumerable .Repeat(0, 100) .Select(n => (char)new Random().Next(97, 123) ) ); // Act var fixedChannelName = ChannelName.Create(channelNameOfLength100); // Assert AssertValidSlackChannelName(fixedChannelName); }
public async Task CreateChannel_Given_valid_input_Should_create_channel() { // Arrange var sut = new SlackFacade(_httpClient, _slackOptions, null); var channelName = ChannelName.Create(Guid.NewGuid().ToString()); // Act var createChannelResponse = await sut.CreateChannel(channelName.ToString()); // Assert Assert.True(createChannelResponse.Ok); Assert.Equal(channelName, createChannelResponse.Channel.Name); Assert.NotEmpty(createChannelResponse.Channel.Id.ToString()); //Clean up integration test resources. await sut.ArchiveChannel(createChannelResponse.Channel.Id); }
public async Task InviteToChannel_Given_valid_input_Should_invite_to_channel() { // Arrange var sut = new SlackFacade(_httpClient, _slackOptions, null, new MemoryCache(new MemoryCacheOptions())); var channelName = ChannelName.Create(Guid.NewGuid().ToString()); var userEmail = _configuration.SLACK_TESTING_USER_EMAIL; // Act var createChannelResponse = await sut.CreateChannel(channelName.ToString()); await sut.InviteToChannel(userEmail, createChannelResponse.Channel.Id.ToString()); // Assert Assert.True(createChannelResponse.Ok); //Clean up integration test resources. await sut.ArchiveChannel(createChannelResponse.Channel.Id); }
public async Task SendNotificationToChannel_Given_valid_input_Should_send_notfication_to_channel() { // Arrange var sut = new SlackFacade(_httpClient, _slackOptions, null, new MemoryCache(new MemoryCacheOptions())); var channelName = ChannelName.Create(Guid.NewGuid().ToString()); const string message = "Integration test message."; // Act var createChannelResponse = await sut.CreateChannel(channelName.ToString()); var sendNotificationToChannelResponse = await sut.SendNotificationToChannel(createChannelResponse.Channel.Id, message : message); // Assert Assert.True(sendNotificationToChannelResponse.Ok); Assert.NotEmpty(sendNotificationToChannelResponse.TimeStamp); //Clean up integration test resources. await sut.ArchiveChannel(createChannelResponse.Channel.Id); }
public async Task HandleAsync(CreateChannelCommand command) { var groupId = GroupId.From(command.GroupId); var group = await _groupRepository.GetAsync(groupId) ?? throw new GroupNotFoundException(groupId); if (await _channelRepository.ExistsAsync(group.Id, ChannelId.From(command.ChannelId))) { throw new ChannelAlreadyExistsException(command.ChannelId); } var channel = group.CreateChannel(UserId.From(command.UserId), ChannelId.From(command.ChannelId), ChannelName.Create(command.ChannelName)); await _channelRepository.AddAsync(channel); }