コード例 #1
0
        public async Task FindParticipantAsync_ShouldBeNotFoundObjectResult()
        {
            // Arrange
            TestMock.ParticipantQuery.Setup(participantQuery => participantQuery.FindParticipantAsync(It.IsAny <ParticipantId>())).Verifiable();

            var controller = new ParticipantsController(TestMock.ParticipantQuery.Object, TestMapper);

            // Act
            var result = await controller.FindParticipantAsync(new ParticipantId());

            // Assert
            result.Should().BeOfType <NotFoundObjectResult>();

            TestMock.ParticipantQuery.Verify(participantQuery => participantQuery.FindParticipantAsync(It.IsAny <ParticipantId>()), Times.Once);
        }
コード例 #2
0
        public async Task FindParticipantAsync_ShouldBeOkObjectResult()
        {
            // Arrange
            var challengeFaker = TestData.FakerFactory.CreateChallengeFaker(95632852, Game.LeagueOfLegends, ChallengeState.InProgress);

            var challenge = challengeFaker.FakeChallenge();

            var participants = challenge.Participants;

            TestMock.ParticipantQuery.Setup(participantQuery => participantQuery.FindParticipantAsync(It.IsAny <ParticipantId>()))
            .ReturnsAsync(participants.First())
            .Verifiable();

            var controller = new ParticipantsController(TestMock.ParticipantQuery.Object, TestMapper);

            // Act
            var result = await controller.FindParticipantAsync(new ParticipantId());

            // Assert
            result.Should().BeOfType <OkObjectResult>();

            TestMock.ParticipantQuery.Verify(participantQuery => participantQuery.FindParticipantAsync(It.IsAny <ParticipantId>()), Times.Once);
        }