コード例 #1
0
ファイル: ClubServiceTests.cs プロジェクト: AlexB101/SLT
        public void Should_correctly_map_club_list()
        {
            // Arrange
            var clubRepository = new Mock <IGenericRepository <Club> >();

            var clubEntities = new Club[] { _testClubEntity }.AsQueryable();

            clubRepository.Setup(c => c.GetAll(It.IsAny <string>())).Returns(clubEntities);

            var clubService = new ClubService(_mapper, null, clubRepository.Object);

            // Act
            var clubListItemDtos = clubService.GetClubListings();

            // Assert
            Assert.That(clubListItemDtos, Is.Not.Null);
            Assert.That(clubListItemDtos.Count(), Is.EqualTo(clubEntities.Count()));

            var returnedClubListItemDto = clubListItemDtos.FirstOrDefault();

            Assert.That(_testClubEntity.Id, Is.EqualTo(returnedClubListItemDto.Id));
            Assert.That(_testClubEntity.Name, Is.EqualTo(returnedClubListItemDto.Name));
            Assert.That(_testClubEntity.Eliminated.ToString(), Is.EqualTo(returnedClubListItemDto.Eliminated));
        }