Ejemplo n.º 1
0
        public async Task Payment_Expense_NoXmlTags_ReturnsValidationError()
        {
            //No xml in raw text, validation error

            var text = @"Hi Yvaine, Please create an expense claim for the below.";

            var request = CreateRequest(text);

            SetAuthHeader();

            var response = await client.PostAsync(request.Url, ContentHelper.GetStringContent(request.Body));

            var value = await response.Content.ReadAsAsync <ExpenseResponse>();

            response.EnsureSuccessStatusCode();

            Assert.Equal("Failed", value.ExecutionResult.Status);
            Assert.True(value.ExecutionResult.Errors.Any());
        }
Ejemplo n.º 2
0
        public async Task Payment_Expense_InvalidXml_ReturnsValidationError()
        {
            //2 cost_centre elements, one does not have a closing tag, validation error

            var text = @"Hi Yvaine, Please create an expense claim for the below. <expense><cost_centre><cost_centre>DEV002</cost_centre></expense>.";

            var request = CreateRequest(text);

            SetAuthHeader();

            var response = await client.PostAsync(request.Url, ContentHelper.GetStringContent(request.Body));

            var value = await response.Content.ReadAsAsync <ExpenseResponse>();

            response.EnsureSuccessStatusCode();

            Assert.Equal("Failed", value.ExecutionResult.Status);
            Assert.Contains(value.ExecutionResult.Errors, e => e.Contains("Invalid Xml in text"));
        }
Ejemplo n.º 3
0
        public async Task Payment_Expense_ValidInput_NoCostCenter_ReturnsResponse()
        {
            //Valid Xml, return response

            var text = @"Hi Yvaine,

                        Please create an expense claim for the below. Relevant details are marked up as requested…

                        <expense><total>1024.01</total><payment_method>personal card</payment_method> </expense>
                        
                        From: Ivan Castle 
                        Sent: Friday, 16 February 2018 10:32 AM 
                        To: Antoine Lloyd <*****@*****.**> 
                        Subject: test

                        Hi Antoine,
                        
                        Please create a reservation at the <vendor>Viaduct Steakhouse</vendor> our <description>development team’s project end celebration dinner</description> on <date>Tuesday 27 April 2017</date>. We expect to arrive around 7.15pm. Approximately 12 people but I’ll confirm exact numbers closer to the day.
                        
                        Regards,
                        Ivan";

            var request = CreateRequest(text);

            SetAuthHeader();

            var response = await client.PostAsync(request.Url, ContentHelper.GetStringContent(request.Body));

            var value = await response.Content.ReadAsAsync <ExpenseResponse>();

            response.EnsureSuccessStatusCode();

            Assert.Equal("Success", value.ExecutionResult.Status);
            Assert.Equal("UNKNOWN", value.CostCentre);
            Assert.Equal(1024.01M, value.Total);
            Assert.True(value.TotalExcludingGST > 0 && value.TotalExcludingGST <= value.Total);
        }