コード例 #1
0
        public async Task CreateOrUpdate_Validate_Failed(
            bool pAdministrationCode,
            bool pIdCompany,
            bool pName,
            GLAccount pGLAccountInput,
            [Frozen] IBlue10AsyncClient pBlue10AsyncCLient,
            GLAccountService pGLAccountService)
        {
            // Setup data
            if (pAdministrationCode)
            {
                pGLAccountInput.AdministrationCode = string.Empty;
            }
            if (pIdCompany)
            {
                pGLAccountInput.IdCompany = string.Empty;
            }
            if (pName)
            {
                pGLAccountInput.Name = string.Empty;
            }

            // Setup validatione
            var fErrors = new List <string>();

            if (pAdministrationCode)
            {
                fErrors.Add("AdministrationCode is empty");
            }
            if (pIdCompany)
            {
                fErrors.Add("IdCompany is empty");
            }
            if (pName)
            {
                fErrors.Add("Name is empty");
            }
            var fExpected = string.Join(", ", fErrors);

            // Test
            var fResult = await pGLAccountService.CreateOrUpdate(pGLAccountInput);

            // Validate
            pBlue10AsyncCLient.DidNotReceive();
            fResult.Should().BeOfType <BaseResultModel <GLAccount> >();
            fResult.Object.Should().BeNull();
            fResult.ErrorMessage.Should().Be(fExpected);
        }
コード例 #2
0
        public async Task CreateOrUpdate_Update_Success(
            GLAccount pGLAccountInput,
            GLAccount pGLAccountResult,
            [Frozen] IBlue10AsyncClient pBlue10AsyncCLient,
            GLAccountService pGLAccountService)
        {
            // Setup services
            pBlue10AsyncCLient.EditGLAccountAsync(Arg.Any <GLAccount>()).Returns(pGLAccountResult);

            // Test
            var fResult = await pGLAccountService.CreateOrUpdate(pGLAccountInput);

            // Validate
            pBlue10AsyncCLient.Received(1);
            await pBlue10AsyncCLient.Received().EditGLAccountAsync(Arg.Is <GLAccount>(x => x.Equals(pGLAccountInput)));

            fResult.Should().BeOfType <BaseResultModel <GLAccount> >();
            fResult.ErrorMessage.Should().BeNull();
            fResult.Object.Should().Be(pGLAccountResult);
        }