Example #1
0
        public async Task GetStatistics_MemberIdIsValide_ShouldReturnMemberStatistics()
        {
            // arrange
            var memberId = _fixture.Create <int>();

            var expectedMemberName = _fixture.Create <string>();

            var expectedMembers = _fixture.Build <MemberStatistic>()
                                  .With(x => x.MemberName, expectedMemberName)
                                  .CreateMany()
                                  .ToArray();

            _membersRepositoryMock.Setup(x => x.GetStatistics(memberId))
            .ReturnsAsync(expectedMembers);

            // act
            var memberStatisrics = await _service.GetStatistics(memberId);

            // assert
            memberStatisrics.Should()
            .NotBeNull()
            .And
            .HaveCount(expectedMembers.Length)
            .And
            .Match <MemberStatistic[]>(x => x.All(f => f.MemberName == expectedMemberName));

            _membersRepositoryMock.Verify(x => x.GetStatistics(memberId), Times.Once);
        }