Exemplo n.º 1
0
        public async Task CreateOrUpdate_Validate_Failed(
            bool pAdministrationCode,
            bool pIdCompany,
            bool pName,
            Vendor pVendorInput,
            [Frozen] IBlue10AsyncClient pBlue10AsyncCLient,
            VendorService pVendorService)
        {
            // Setup data
            if (pAdministrationCode)
            {
                pVendorInput.AdministrationCode = string.Empty;
            }
            if (pIdCompany)
            {
                pVendorInput.IdCompany = string.Empty;
            }
            if (pName)
            {
                pVendorInput.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 pVendorService.CreateOrUpdate(pVendorInput);

            // Validate
            pBlue10AsyncCLient.DidNotReceive();
            fResult.Should().BeOfType <BaseResultModel <Vendor> >();
            fResult.Object.Should().BeNull();
            fResult.ErrorMessage.Should().Be(fExpected);
        }