Exemplo n.º 1
0
        public async Task CreateAccount_Run_Success()
        {
            // arrange
            var mock = new Mock <ILogger>();
            var createAccountFunction = new CreateAccount(_mediatorService);
            var createAccountRequest  = new HttpRequestMessage
            {
                Headers =
                {
                    Authorization = HttpRequestMessageUtils.GetAuthorization()
                },
                Content = new StringContent(JsonConvert.SerializeObject(new CreateAccountCommand
                {
                    Balance           = 3,
                    UserId            = _userId,
                    BankAccountNumber = "DE89370400440532013000"
                }), Encoding.UTF8, "application/json")
            };

            // act
            var result = await createAccountFunction.Run(createAccountRequest, mock.Object, CancellationToken.None);

            // assert
            Assert.Multiple(() =>
            {
                Assert.IsInstanceOf <OkObjectResult>(result);
                Assert.AreEqual(1, ((OkObjectResult)result).Value);
            });
        }
Exemplo n.º 2
0
        public async Task UpdateAccount_Run_Success()
        {
            // arrange
            var mock = new Mock <ILogger>();
            var updateAccountFunction = new UpdateAccount(_mediatorService);
            var updateAccountRequest  = new HttpRequestMessage
            {
                Headers =
                {
                    Authorization = HttpRequestMessageUtils.GetAuthorization()
                },
                Content = new StringContent(JsonConvert.SerializeObject(new UpdateAccountCommand
                {
                    BankAccountNumber = "CH9300762011623852957"
                }), Encoding.UTF8, "application/json")
            };

            // act
            var result = await updateAccountFunction.Run(updateAccountRequest, mock.Object, CancellationToken.None);

            // assert
            Assert.Multiple(() => { Assert.IsInstanceOf <OkResult>(result); });
        }
Exemplo n.º 3
0
        public async Task CreateAccount_Run_FailValidations()
        {
            // arrange
            var mock = new Mock <ILogger>();
            var createAccountFunction = new CreateAccount(_mediatorService);
            var createAccountRequest  = new HttpRequestMessage
            {
                Headers =
                {
                    Authorization = HttpRequestMessageUtils.GetAuthorization()
                },
                Content = new StringContent(JsonConvert.SerializeObject(new CreateAccountCommand
                {
                    Balance           = 3,
                    BankAccountNumber = "123445544"
                }), Encoding.UTF8, "application/json")
            };

            // act
            var result = await createAccountFunction.Run(createAccountRequest, mock.Object, CancellationToken.None);

            // assert
            Assert.Multiple(() => { Assert.IsInstanceOf <BadRequestObjectResult>(result); });
        }