Exemplo n.º 1
0
        public async Task ShouldReturnARecord_WhenCallingGetByIdAndDataExisting()
        {
            var mockResult = CreditCardGenerator.CreateValidCreditCardOutputFaker().Generate();

            _mediatorMock.Setup(m =>
                                m.Send(It.IsAny <GetCreditCardByIdQuery>(), It.IsAny <CancellationToken>())).ReturnsAsync(mockResult);

            var response = await _controller.GetById(mockResult.Id);

            if (response is OkObjectResult result)
            {
                var record = result.Value as CreditCartOutput;
                Assert.IsType <OkObjectResult>(response);
                Assert.Equal(mockResult, record);
            }
        }
Exemplo n.º 2
0
        public async Task ShouldReturnListOfRecords_WhenCallingGet()
        {
            var mockResult = CreditCardGenerator.CreateValidCreditCardOutputFaker().Generate(3);

            _mediatorMock.Setup(m =>
                                m.Send(It.IsAny <GetAllCreditCardQuery>(), It.IsAny <CancellationToken>())).ReturnsAsync(mockResult);

            var response = await _controller.Get();

            if (response is OkObjectResult result)
            {
                var recordSet = result.Value as List <CreditCartOutput>;

                Assert.IsType <OkObjectResult>(response);
                Assert.Equal(3, recordSet.Count);
            }
        }