public async Task GivenValidInput_ThenRequestBuilder_AddsCredentials_ToRequest(
            string tenancyRef, string comment, decimal startBalance, string startDate, string agreementStatusCode,
            bool isBreached, int firstCheck, string firstCheckFrequencyTypeCode, int nextCheck, string nextCheckFrequencyTypeCode,
            string fcaDate, string monitorBalanceCode, decimal amount, string arrearsFrequencyCode,
            string payementInfoStartDate, string payemntInfoComments)
        {
            //Arrange
            var fakeArrearsAgreementService = new Mock <IArrearsAgreementServiceChannel>();

            fakeArrearsAgreementService.Setup(s => s.CreateArrearsAgreementAsync(It.IsAny <ArrearsAgreementRequest>()))
            .ReturnsAsync(new ArrearsAgreementResponse());

            var fakeCredentialsService = new Mock <ICredentialsService>();

            fakeCredentialsService.Setup(s => s.GetUhSourceSystem()).Returns("testSourceSystem");
            fakeCredentialsService.Setup(s => s.GetUhUserCredentials()).Returns(new UserCredential
            {
                UserName     = "******",
                UserPassword = "******",
            });
            var serviceRequestBuilder = new ArrearsServiceRequestBuilder(fakeCredentialsService.Object);

            IArrearsAgreementGateway gateway = new ArrearsAgreementGateway(fakeArrearsAgreementService.Object, serviceRequestBuilder);
            var classUnderTest = new CreateArrearsAgreementUseCase(gateway);

            var request = new CreateArrearsAgreementRequest
            {
                AgreementInfo = new ArrearsAgreementInfo
                {
                    TenancyAgreementRef         = tenancyRef,
                    Comment                     = comment,
                    ArrearsAgreementStatusCode  = agreementStatusCode,
                    FcaDate                     = DateTime.Parse(fcaDate),
                    FirstCheck                  = firstCheck,
                    FirstCheckFrequencyTypeCode = firstCheckFrequencyTypeCode,
                    IsBreached                  = isBreached,
                    MonitorBalanceCode          = monitorBalanceCode,
                    NextCheck                   = nextCheck,
                    NextCheckFrequencyTypeCode  = nextCheckFrequencyTypeCode,
                    StartBalance                = startBalance,
                    StartDate                   = DateTime.Parse(startDate)
                },
                PaymentSchedule = new List <ArrearsScheduledPaymentInfo>
                {
                    new ArrearsScheduledPaymentInfo
                    {
                        Amount = amount,
                        ArrearsFrequencyCode = arrearsFrequencyCode,
                        Comments             = payemntInfoComments,
                        StartDate            = DateTime.Parse(payementInfoStartDate)
                    }
                }.ToArray()
            };

            fakeArrearsAgreementService.Setup(s => s.CreateArrearsAgreementAsync(It.IsAny <ArrearsAgreementRequest>()))
            .ReturnsAsync(new ArrearsAgreementResponse
            {
                Success   = true,
                Agreement = new ArrearsAgreementDto
                {
                    TenancyAgreementRef         = tenancyRef,
                    Comment                     = comment,
                    ArrearsAgreementStatusCode  = agreementStatusCode,
                    FcaDate                     = DateTime.Parse(fcaDate),
                    FirstCheck                  = firstCheck,
                    FirstCheckFrequencyTypeCode = firstCheckFrequencyTypeCode,
                    IsBreached                  = isBreached,
                    MonitorBalanceCode          = monitorBalanceCode,
                    NextCheck                   = nextCheck,
                    NextCheckFrequencyTypeCode  = nextCheckFrequencyTypeCode,
                    StartBalance                = startBalance,
                    StartDate                   = DateTime.Parse(startDate),

                    PaymentSchedule = new List <ArrearsScheduledPaymentDto>
                    {
                        new ArrearsScheduledPaymentDto
                        {
                            Amount = amount,
                            ArrearsFrequencyCode = arrearsFrequencyCode,
                            Comments             = payemntInfoComments,
                            StartDate            = DateTime.Parse(payementInfoStartDate)
                        }
                    }.ToArray()
                },
            });
            //act
            await classUnderTest.ExecuteAsync(request, CancellationToken.None);

            //assert
            fakeArrearsAgreementService.Verify(v => v.CreateArrearsAgreementAsync(It.Is <ArrearsAgreementRequest>(i => i.DirectUser != null && !string.IsNullOrEmpty(i.SourceSystem))));
        }
        public async Task GivenInValidInput_ThenUseCase_ShouldReturnInValidResponse(
            string tenancyRef, string comment, decimal startBalance, string startDate, string agreementStatusCode,
            bool isBreached, int firstCheck, string firstCheckFrequencyTypeCode, int nextCheck, string nextCheckFrequencyTypeCode,
            string fcaDate, string monitorBalanceCode, decimal amount, string arrearsFrequencyCode,
            string payementInfoStartDate, string payemntInfoComments)
        {
            //Arrange
            var fakeArrearsAgreementService = new Mock <IArrearsAgreementServiceChannel>();

            fakeArrearsAgreementService.Setup(s => s.CreateArrearsAgreementAsync(It.IsAny <ArrearsAgreementRequest>()))
            .ReturnsAsync(new ArrearsAgreementResponse
            {
                Success      = false,
                ErrorCode    = 1,
                ErrorMessage = "Not enough field",
                Agreement    = new ArrearsAgreementDto
                {
                    TenancyAgreementRef = tenancyRef,
                    Comment             = comment,
                },
            });

            var fakeCredentialsService = new Mock <ICredentialsService>();

            fakeCredentialsService.Setup(s => s.GetUhSourceSystem()).Returns("testSourceSystem");
            fakeCredentialsService.Setup(s => s.GetUhUserCredentials()).Returns(new UserCredential
            {
                UserName     = "******",
                UserPassword = "******",
            });
            var serviceRequestBuilder = new ArrearsServiceRequestBuilder(fakeCredentialsService.Object);

            IArrearsAgreementGateway gateway = new ArrearsAgreementGateway(fakeArrearsAgreementService.Object, serviceRequestBuilder);
            var classUnderTest = new CreateArrearsAgreementUseCase(gateway);

            var request = new CreateArrearsAgreementRequest
            {
                AgreementInfo = new ArrearsAgreementInfo
                {
                    TenancyAgreementRef         = tenancyRef,
                    Comment                     = comment,
                    ArrearsAgreementStatusCode  = agreementStatusCode,
                    FcaDate                     = DateTime.Parse(fcaDate),
                    FirstCheck                  = firstCheck,
                    FirstCheckFrequencyTypeCode = firstCheckFrequencyTypeCode,
                    IsBreached                  = isBreached,
                    MonitorBalanceCode          = monitorBalanceCode,
                    NextCheck                   = nextCheck,
                    NextCheckFrequencyTypeCode  = nextCheckFrequencyTypeCode,
                    StartBalance                = startBalance,
                    StartDate                   = DateTime.Parse(startDate)
                },
                PaymentSchedule = new List <ArrearsScheduledPaymentInfo>
                {
                    new ArrearsScheduledPaymentInfo
                    {
                        Amount = amount,
                        ArrearsFrequencyCode = arrearsFrequencyCode,
                        Comments             = payemntInfoComments,
                        StartDate            = DateTime.Parse(payementInfoStartDate)
                    }
                }.ToArray()
            };


            //act
            var response = await classUnderTest.ExecuteAsync(request, CancellationToken.None);

            //assert
            response.IsSuccess.Should().BeFalse();
            response.Result.Should().BeNull();
            response.Error.Errors.Should().NotBeNullOrEmpty();
            response.Error.Errors[0].Code.Should().Be("UH_1");
            response.Error.Errors[0].Message.Should().Be("Not enough field");
        }