Exemple #1
0
        public async Task Get_ShouldCallMethodsCorrectly(
            List <Goal> goals,
            List <GoalModel> goalModels,
            GoalController sut)
        {
            // Arranges
            sut.GoalService.GetAllAsync().Returns(goals);
            sut.GoalMapper.Map(Arg.Is(goals)).Returns(goalModels);

            // Act
            var result = await sut.Get();

            // Asserts
            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();
            ((OkObjectResult)result).Value.Should().BeEquivalentTo(goalModels);
            await sut.GoalService.Received(1).GetAllAsync();

            sut.GoalMapper.Received(1).Map(Arg.Is(goals));
        }