Skip to content

Commit 4dbf343

Browse files
committed
[#5] [add] impl
1 parent 835e14b commit 4dbf343

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Collections.Generic;
2+
using Simplify.Web.Postman.Models;
3+
4+
namespace Simplify.Web.Postman.Assembly.Collection.PartBuilders
5+
{
6+
/// <summary>
7+
/// Provides basic tests builder
8+
/// </summary>
9+
/// <seealso cref="ICollectionPartBuilder" />
10+
public static class BasicTestsBuilder
11+
{
12+
/// <summary>
13+
/// Builds the basic test.
14+
/// </summary>
15+
public static Event Build()
16+
{
17+
return new Event
18+
{
19+
Listen = "test",
20+
Script = new Script
21+
{
22+
Exec = new List<string> { "tests[\"HTTP Code Test\"] = pm.expect(pm.response.code).to.be.oneOf([200, 204]);" },
23+
Type = "text/javascript"
24+
}
25+
};
26+
}
27+
}
28+
}

src/Simplify.Web.Postman/Assembly/Collection/PartBuilders/CollectionItemsBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ private static CollectionItem BuildRequestCollectionItem(IControllerMetaData met
6868
new()
6969
{
7070
Name = BuildRequestName(metaData),
71-
Request = RequestBuilder.Build(metaData, route)
71+
Request = RequestBuilder.Build(metaData, route),
72+
Event = new List<Models.Event> { BasicTestsBuilder.Build() }
7273
};
7374

7475
private static string BuildRequestName(IControllerMetaData metaData) => metaData.ControllerType.Name.Replace("Controller", "");

src/Simplify.Web.Postman/Assembly/Collection/PartBuilders/RequestBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static Request Build(IControllerMetaData metaData, KeyValuePair<HttpMetho
4949

5050
private static Body? TryBuildBody(IControllerMetaData metaData)
5151
{
52-
if (metaData.ControllerType.BaseType.GenericTypeArguments.Length == 0)
52+
if (metaData.ControllerType.BaseType!.GenericTypeArguments.Length == 0)
5353
return null;
5454

5555
var body = new Body()

src/Simplify.Web.Postman/Models/Script.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System.Collections.Generic;
22

3+
#nullable disable
4+
35
namespace Simplify.Web.Postman.Models
46
{
57
/// <summary>
@@ -11,5 +13,10 @@ public class Script
1113
/// Provides script commands list
1214
/// </summary>
1315
public IList<string> Exec { get; set; }
16+
17+
/// <summary>
18+
/// Gets of sets the script type
19+
/// </summary>
20+
public string Type { get; set; }
1421
}
1522
}

0 commit comments

Comments
 (0)