Esempio n. 1
0
        public void ResolveAuthor_WithoutKnownAuthor_ExpectUserAskedForUsername()
        {
            //Arrange
            fileOperationService.GetUserMap().Returns(users);
            userInteractionService.AskForAuthor(Author4, users).Returns(user.Id);
            var chatEntry = SmeuTestDataFactory.NewChatEntry(Author4);

            //Act
            var result = authorService.ResolveAuthorId(chatEntry);

            //Assert
            result.Should().Be(user.Id);
        }
Esempio n. 2
0
        public ulong ResolveAuthorId(ChatEntry chatEntry)
        {
            var userMap = fileOperationService.GetUserMap();
            var userId  = userMap.SingleOrDefault(map => map.Names.Contains(chatEntry.Author))?.Id ?? 0;

            if (userId != 0)
            {
                return(userId);
            }

            userId = userInteractionService.AskForAuthor(chatEntry.Author, userMap);
            userMap.Single(map => map.Id == userId).Names.Add(chatEntry.Author);
            fileOperationService.SetUserMap(userMap);
            return(userId);
        }