1
1
var expect = require ( 'chai' ) . expect ,
2
2
path = require ( 'path' ) ,
3
3
sdk = require ( 'postman-collection' ) ,
4
- newmanTestUtil = require ( '../../../../test/codegen/newman/newmanTestUtil' ) ,
5
- async = require ( 'async' ) ,
4
+ runNewmanTest = require ( '../../../../test/codegen/newman/newmanTestUtil' ) . runNewmanTest ,
6
5
convert = require ( '../../lib/index' ) . convert ,
7
6
mainCollection = require ( './fixtures/testcollection/collection.json' ) ,
8
7
testCollection = require ( './fixtures/testcollection/collectionForEdge.json' ) ,
@@ -13,55 +12,17 @@ var expect = require('chai').expect,
13
12
14
13
describe ( 'csharp restsharp function' , function ( ) {
15
14
describe ( 'convert for different request types' , function ( ) {
16
- var headerSnippet = 'using System;\n' +
17
- 'using RestSharp;\n' +
18
- 'namespace HelloWorldApplication {\n' +
19
- 'class HelloWorld {\n' +
20
- 'static void Main(string[] args) {\n' ,
21
- footerSnippet = '}\n}\n}\n' ,
22
- depedenciesPath = path . resolve ( __dirname , 'fixtures/dependencies' ) ,
15
+ var depedenciesPath = path . resolve ( __dirname , 'fixtures/dependencies' ) ,
23
16
testConfig = {
24
17
compileScript : `mcs -reference:${ depedenciesPath } /RestSharp.dll` +
25
18
` -out:${ depedenciesPath } /main.exe ${ depedenciesPath } /main.cs` ,
26
19
runScript : `mono ${ depedenciesPath } /main.exe` ,
27
20
fileName : `${ depedenciesPath } /main.cs`
28
21
} ,
29
22
options = {
30
- indentCount : 1 ,
31
- indentType : 'Tab'
23
+ includeBoilerplate : true
32
24
} ;
33
- async . waterfall ( [
34
- function ( next ) {
35
- newmanTestUtil . generateSnippet ( convert , options , function ( error , snippets ) {
36
- if ( error ) {
37
- expect . fail ( null , null , error ) ;
38
- return next ( error ) ;
39
- }
40
-
41
- return next ( null , snippets ) ;
42
- } ) ;
43
- } ,
44
- function ( snippets , next ) {
45
- snippets . forEach ( ( item , index ) => {
46
- it ( item . name , function ( done ) {
47
- newmanTestUtil . runSnippet ( headerSnippet + item . snippet + footerSnippet , index , testConfig ,
48
- function ( err , result ) {
49
- if ( err ) {
50
- expect . fail ( null , null , err ) ;
51
- }
52
- if ( typeof result [ 1 ] !== 'object' || typeof result [ 0 ] !== 'object' ) {
53
- expect ( result [ 0 ] . toString ( ) . trim ( ) ) . to . include ( result [ 1 ] . toString ( ) . trim ( ) ) ;
54
- }
55
- else {
56
- expect ( result [ 0 ] ) . deep . equal ( result [ 1 ] ) ;
57
- }
58
- return done ( null ) ;
59
- } ) ;
60
- } ) ;
61
- } ) ;
62
- return next ( null ) ;
63
- }
64
- ] ) ;
25
+ runNewmanTest ( convert , options , testConfig ) ;
65
26
} ) ;
66
27
67
28
describe ( 'csharp-restsharp convert function' , function ( ) {
0 commit comments