public void ResolveAuthor_WithMultipleAuthorsKnown_ExpectCorrectIdFound() { //Arrange fileOperationService.GetUserMap().Returns(users); var chatEntry = SmeuTestDataFactory.NewChatEntry(Author2); //Act var result = authorService.ResolveAuthorId(chatEntry); //Assert result.Should().Be(user.Id); }
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); }
public void ResolveAuthor_WithoutKnownAuthor_ExpectAuthor4AddedToAuthors() { //Arrange fileOperationService.GetUserMap().Returns(users); userInteractionService.AskForAuthor(Author4, users).Returns(user.Id); var chatEntry = SmeuTestDataFactory.NewChatEntry(Author4); //Act var result = authorService.ResolveAuthorId(chatEntry); //Assert fileOperationService.Received(1) .SetUserMap(Arg.Is <List <User> >(userMap => userMap.SelectMany(row => row.Names).Contains(Author4))); }
public void Setup() { authorService = new AuthorService(fileOperationService, userInteractionService); user = SmeuTestDataFactory.NewUser(3, new List <string> { Author, Author2 }); user2 = SmeuTestDataFactory.NewUser(4, new List <string> { Author3 }); users = new List <User> { user, user2 }; }
public void SetUserMap_WithJson_ExpectJsonCorrectlyWritten() { var user1 = SmeuTestDataFactory.NewUser(3, new List <string> { Author1 }); var userMap = new List <User>() { user1 }; fileOperationService.SetUserMap(userMap); var file = File.ReadAllText(System.AppDomain.CurrentDomain.BaseDirectory + "/userids.json"); var result = JsonConvert.DeserializeObject <List <User> >(file); result.Count.Should().Be(1); result.First().Id.Should().Be(user1.Id); result.First().Names.Count.Should().Be(1); result.First().Names.First().Should().Be(Author1); }