Ejemplo n.º 1
0
        public void UpdateBP_IncorrectBP_ExceptionRaised()
        {
            var updateBP = new UpdateBusinessPartner
            {
                Url     = "https://starbucks.com",
                Fax     = "(206) 447-1575",
                Address = new Address
                {
                    Street2 = "Suite 800",
                    State   = "WA"
                }
            };

            var client = CreateClient();
            var ex     = Assert.Throws <WebServiceException>(() => client.Put <BusinessPartnerResponse>(updateBP));

            Assert.IsTrue(ex.ResponseStatus.Errors.Count == 8);
            Assert.IsTrue(ex.ResponseStatus.Errors.Any(e => e.ErrorCode == "NotEmpty" && e.Message == "Specify Id for BusinessPartner."));
            Assert.IsTrue(ex.ResponseStatus.Errors.Any(e => e.ErrorCode == "NotEmpty" && e.Message == "Specify Name for BusinessPartner."));
            Assert.IsTrue(ex.ResponseStatus.Errors.Any(e => e.ErrorCode == "NotEmpty" && e.Message == "Specify Email for BusinessPartner."));
            Assert.IsTrue(ex.ResponseStatus.Errors.Any(e => e.ErrorCode == "NotEmpty" && e.Message == "Specify Telephone for BusinessPartner."));
            Assert.IsTrue(ex.ResponseStatus.Errors.Any(e => e.ErrorCode == "NotEmpty" && e.Message == "Specify Street1 of Address."));
            Assert.IsTrue(ex.ResponseStatus.Errors.Any(e => e.ErrorCode == "NotEmpty" && e.Message == "Specify City of Address."));
            Assert.IsTrue(ex.ResponseStatus.Errors.Any(e => e.ErrorCode == "NotEmpty" && e.Message == "Specify ZipCode of Address."));
            Assert.IsTrue(ex.ResponseStatus.Errors.Any(e => e.ErrorCode == "NotEmpty" && e.Message == "Specify Country of Address."));
        }
Ejemplo n.º 2
0
        public BusinessPartnerResponse Put(UpdateBusinessPartner request)
        {
            try
            {
                BusinessPartnerModel bpModel     = request.ConvertTo <BusinessPartnerModel>();
                var replaceResult                = businessPartnerRepository.Upsert(bpModel);
                BusinessPartnerResponse response = bpModel.ConvertTo <BusinessPartnerResponse>();

                if (!replaceResult.IsAcknowledged)
                {
                    Log.Error($"Upsert operation was not Acknowledged for BusinessPartner with Id:{request.Id} Name:{request.Name}.");
                    throw new Exception($"Upsert operation was not Acknowledged for BusinessPartner with Id:{request.Id} Name:{request.Name}.");
                }

                if (replaceResult.UpsertedId != null)
                {
                    response.Id = replaceResult.UpsertedId.AsGuid;
                }

                return(response);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Something went wrong while upserting BusinessPartner.");
                throw;
            }
        }
Ejemplo n.º 3
0
        public void UpdateBP_CorrectBP_BPUpdated()
        {
            var updateBP = new UpdateBusinessPartner
            {
                Id        = starbucksBPResponse.Id,
                Name      = "Starbucks Corp.",
                Email     = starbucksBP.Email,
                Url       = starbucksBP.Url,
                Telephone = starbucksBP.Telephone,
                Fax       = starbucksBP.Fax,
                Address   = starbucksBP.Address
            };

            var service  = appHost.Container.Resolve <BusinessPartnerService>();
            var response = service.Put(updateBP);

            Assert.IsTrue(response.Name.Equals("Starbucks Corp.", StringComparison.InvariantCulture));
        }