예제 #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);
        }
예제 #2
0
        public async Task CreateOrUpdate_Update_Success(
            Vendor pVendorInput,
            Vendor pVendorResult,
            [Frozen] IBlue10AsyncClient pBlue10AsyncCLient,
            VendorService pVendorService)
        {
            // Setup services
            pBlue10AsyncCLient.EditVendorAsync(Arg.Any <Vendor>()).Returns(pVendorResult);

            // Test
            var fResult = await pVendorService.CreateOrUpdate(pVendorInput);

            // Validate
            pBlue10AsyncCLient.Received(1);
            await pBlue10AsyncCLient.Received().EditVendorAsync(Arg.Is <Vendor>(x => x.Equals(pVendorInput)));

            fResult.Should().BeOfType <BaseResultModel <Vendor> >();
            fResult.ErrorMessage.Should().BeNull();
            fResult.Object.Should().Be(pVendorResult);
        }