public void RegisterUser_WithUnknownUser_ReturnsNewUser() { // Arrange IUserRepository userRepository = UserRepositoryMockFactory.CreateWithUnknownUser(); var registrationService = GetRegistrationService(userRepository); // Act var result = registrationService.RegisterUser( name: It.IsAny <string>(), email: It.IsAny <string>(), dateOfBirth: It.IsAny <DateTime>()); // Assert result.Should().BeOfType <NewUser>(); }
public void RegisterUser_WithUnknownUser_AddGetsCalledOnce() { // Arrange Mock <IUserRepository> userRepositoryMock = UserRepositoryMockFactory.CreateMockWithUnknownUser(); var registrationService = GetRegistrationService(userRepositoryMock.Object); // Act var result = registrationService.RegisterUser( name: It.IsAny <string>(), email: It.IsAny <string>(), dateOfBirth: It.IsAny <DateTime>()); // Assert userRepositoryMock.Verify(mock => mock.Add( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>()), Times.Once); }