예제 #1
0
        public GetAll()
        {
            _fakeRepository = new FakeRepository();
            SpeakerFactory.Create(_fakeRepository);

            _speakerService = new SpeakerService(_fakeRepository);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }