public GetAll() { _fakeRepository = new FakeRepository(); SpeakerFactory.Create(_fakeRepository); _speakerService = new SpeakerService(_fakeRepository); }
public Search() { var fakeRepository = new FakeRepository(); SpeakerFactory.Create(fakeRepository); SpeakerFactory.Create(fakeRepository, name: "Josh"); SpeakerFactory.Create(fakeRepository, name: "Joseph"); SpeakerFactory.Create(fakeRepository, name: "Bill"); _speakerService = new SpeakerService(fakeRepository); }
public void ItCallsRepository() { // Arrange var expectedSpeaker = SpeakerFactory.Create(_fakeRepository); var service = new SpeakerService(_fakeRepository, _fakeGravatarService); // Act service.Get(expectedSpeaker.Id); // Assert Assert.True(_fakeRepository.GetCalled); }
public void GivenSpeakerIsDeletedThenSpeakerNotFoundException() { // Arrange var expectedSpeaker = SpeakerFactory.Create(_fakeRepository).IsDeleted(); var service = new SpeakerService(_fakeRepository, _fakeGravatarService); // Act var exception = Record.Exception(() => service.Get(expectedSpeaker.Id)); // Assert Assert.IsAssignableFrom <SpeakerNotFoundException>(exception); }
public void GivenSpeakerReturnsSpeakerWithProperties() { // Arrange var expectedSpeaker = SpeakerFactory.Create(_fakeRepository); var service = new SpeakerService(_fakeRepository, _fakeGravatarService); // Act var speaker = service.Get(1); // Assert Assert.Equal(expectedSpeaker.Id, speaker.Id); Assert.Equal(expectedSpeaker.Name, speaker.Name); }
public void ItCallsGravatarServiceWithEmail() { // Arrange var expectedSpeaker = SpeakerFactory.Create(_fakeRepository, emailAddress: "*****@*****.**"); var service = new SpeakerService(_fakeRepository, _fakeGravatarService); // Act service.Get(expectedSpeaker.Id); // Assert Assert.True(_fakeGravatarService.WithEmailCalled); Assert.Equal(expectedSpeaker.EmailAddress, _fakeGravatarService.CalledWith); }
public void ItReturnsSpeakerFromRepository(int id, string name) { // Arrange var expectedSpeaker = SpeakerFactory.Create(_fakeRepository, id, name); var service = new SpeakerService(_fakeRepository, _fakeGravatarService); // Act var actualSpeaker = service.Get(expectedSpeaker.Id); // Assert Assert.True(_fakeRepository.GetCalled); Assert.Equal(expectedSpeaker.Id, actualSpeaker.Id); Assert.Equal(expectedSpeaker.Name, actualSpeaker.Name); }
public void ItReturnsSpeakerFromRepository() { // Arrange var fakeRepository = new FakeRepository(); var expectedSpeaker = SpeakerFactory.Create(fakeRepository, 2, "Bill"); var service = new SpeakerService(fakeRepository); // Act var actualSpeaker = service.Get(expectedSpeaker.Id); // Assert Assert.True(fakeRepository.GetCalled); Assert.Equal(expectedSpeaker.Id, actualSpeaker.Id); Assert.Equal(expectedSpeaker.Name, actualSpeaker.Name); }
public void GivenGravatarServiceThenItSetsGravatar() { // Arrange var expectedSpeaker = SpeakerFactory.Create(_fakeRepository); var service = new SpeakerService(_fakeRepository, _fakeGravatarService); // Act var actualSpeaker = service.Get(expectedSpeaker.Id); var expectedGravatar = _fakeGravatarService.GetGravatar(expectedSpeaker.EmailAddress); // Assert Assert.True(_fakeGravatarService.WithEmailCalled); Assert.Equal(expectedSpeaker.Id, actualSpeaker.Id); Assert.Equal(expectedSpeaker.Name, actualSpeaker.Name); Assert.Equal(expectedGravatar, actualSpeaker.Gravatar); }
public void GivenSpeakerIsDeletedSpeakerIsNotReturned() { // Arrange var fakeRepository = new FakeRepository(); SpeakerFactory.Create(fakeRepository).IsDeleted(); var speakerService = new SpeakerService(fakeRepository); // Act var speakers = speakerService.GetAll().ToList(); // Assert Assert.NotNull(speakers); Assert.IsAssignableFrom <IEnumerable <SpeakerSummary> >(speakers); Assert.Equal(0, speakers.Count); }