Exemplo n.º 1
0
        public void CreateBP_IncorrectBP_ExceptionRaised()
        {
            var createBP = new CreateBusinessPartner
            {
                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.Post <BusinessPartnerResponse>(createBP));

            Assert.IsTrue(ex.ResponseStatus.Errors.Count == 7);
            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."));
        }
Exemplo n.º 2
0
        public void CreateBP_CorrectBP_BPCreated()
        {
            var createBP = new CreateBusinessPartner
            {
                Name      = "XYZ Organization",
                Email     = "*****@*****.**",
                Url       = "https://xyz.com",
                Telephone = "123-45-6789",
                Fax       = "123-45-1234",
                Address   = new Address
                {
                    Street1 = "Großer Hirschgraben 15",
                    Street2 = string.Empty,
                    City    = "Frankfurt",
                    ZipCode = "60311",
                    State   = string.Empty,
                    Country = "DE"
                }
            };

            var service  = appHost.Container.Resolve <BusinessPartnerService>();
            var response = service.Post(createBP);

            Assert.IsTrue(response.Id != Guid.Empty);
        }
Exemplo n.º 3
0
        public BusinessPartnerResponse Post(CreateBusinessPartner request)
        {
            try
            {
                BusinessPartnerModel result = request.ConvertTo <BusinessPartnerModel>();
                businessPartnerRepository.Create(result);

                return(result.ConvertTo <BusinessPartnerResponse>());
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Something went wrong while posting BusinessPartner.");
                throw;
            }
        }