Skip to content

Commit 0d9f387

Browse files
author
Ajay kumar
committed
[Blog] [Ajay]: Add FileRef component for file reference display with validation
1 parent b7245ef commit 0d9f387

File tree

5 files changed

+66
-4
lines changed

5 files changed

+66
-4
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@using System.ComponentModel.DataAnnotations
2+
3+
@code {
4+
[Parameter]
5+
[Required]
6+
public string FileName { get; set; }
7+
8+
[Parameter]
9+
public string FilePath { get; set; }
10+
11+
protected override void OnParametersSet()
12+
{
13+
if (string.IsNullOrEmpty(FileName))
14+
{
15+
throw new ArgumentException("FileName is a mandatory parameter.");
16+
}
17+
}
18+
}
19+
20+
@if (!string.IsNullOrEmpty(FilePath))
21+
{
22+
<a class="text-primary" href="@FilePath">@FileName</a>
23+
}
24+
else
25+
{
26+
<span class="text-primary">@FileName</span>
27+
}

TestArena/Blog/PactNet/Intro/ConsumerSideTest.razor

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
@using TestArena.Blog.Common
2+
@using TestArena.Blog.Common.TextDecorators
23

34
@{
45
var listItems = new List<RenderFragment>()
56
{
67
builder => builder.AddContent(0, (RenderFragment)(@<p>First, the logic inside the StudentClient class will be tested to make sure the request that is dispatched from the system to the provider service should contain all the required request attributes that are defined in the unit test.</p>)),
7-
builder => builder.AddContent(0, (RenderFragment)(@<p>Second, a Pact file will be generated with the name ConsumerOneStudent API.json. The naming of the file can be defined at the time of pact builder initialization.</p>))
8+
builder => builder.AddContent(0, (RenderFragment)(@<p>Second, a Pact file will be generated with the name <FileRef FileName="ConsumerOneStudent API.json" FilePath="https://raw.githubusercontent.com/ajaysskumar/pact-net-example/refs/heads/master/pacts/ConsumerOne-Student%20API.json"/>. The naming of the file can be defined at the time of pact builder initialization.</p>))
89
};
910
}
1011

@@ -14,7 +15,7 @@
1415
<p>The very first step is to create a unit test file and initialize pact builder as shown below</p>
1516
<GithubGistSnippet Title="Pact Builder Setup" UserId="ajaysskumar" FileName="c45d40c48ea2a3e2c81719e41df6f882"/>
1617

17-
<p>Next we have to write test and setup scenario. Here below, we are instructing pact builder to return a specific response when it gets a specific request on the mock server (ctx.MockServerUri).</p>
18+
<p>Next we have to write test and setup scenario. Here below, we are instructing pact builder to return a specific response when it gets a specific request on the mock server (<code>ctx.MockServerUri</code>).</p>
1819
<GithubGistSnippet Title="Pact consumer unit test" UserId="ajaysskumar" FileName="fe7bf1fc92a9723d0bce1247a417ba5d"/>
1920

2021
<p>The success test run will look like below</p>
@@ -23,7 +24,7 @@
2324

2425
<List Heading="Once the above test runs, 2 things will happen." HeadingLevel="6" ChildContents="listItems"/>
2526

26-
<p>This pact file needs to be passed to Provider API so that it can be accessed inside unit test, for simplicity here, we have included this file as part of Provider API’s unit test project itself. However, there is much better way which provides many other features, that is called pactflow(https://pactflow.io/ ). It offers free plan as well which can be used to small or test projects.</p>
27+
<p>This pact file needs to be passed to Provider API so that it can be accessed inside unit test, for simplicity here, we have included this file as part of Provider API’s unit test project itself. However, there is much better way which provides many other features, that is called <a href="https://pactflow.io/">pactflow</a>. It offers free plan as well which can be used to small or test projects.</p>
2728

2829
<p>The pact file will look something like below. This file contains, among other details, the request structure that ConsumerOne(Report Card API) will be sending and response that it expects from the Provider API</p>
2930

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@* Footer.razor *@
2+
<footer class="bg-dark text-white py-4 fixed-bottom">
3+
<div class="container-fluid">
4+
<div class="container-fluid">
5+
<div class="row align-items-center">
6+
<!-- Logo on the left -->
7+
<div class="col-12 col-md-4 d-flex justify-content-md-start justify-content-center">
8+
<p class="mb-0">Copyright © @DateTime.Now.Year Dev Arena</p>
9+
</div>
10+
11+
<!-- Settings button on the right -->
12+
<div class="col-12 col-md-8 d-flex justify-content-md-end justify-content-center mt-2 mt-md-0">
13+
@* <a href="https://twitter.com/yourprofile" class="text-white me-3" target="_blank">
14+
<i class="bi bi-twitter"></i>
15+
</a> *@
16+
<a href="https://github.com/ajaysskumar" class="text-white me-3" target="_blank">
17+
<i class="bi bi-github"></i>
18+
</a>
19+
<a href="https://www.linkedin.com/in/ajaykumar1807" class="text-white me-3" target="_blank">
20+
<i class="bi bi-linkedin"></i>
21+
</a>
22+
@* <a href="https://instagram.com/yourprofile" class="text-white me-3" target="_blank">
23+
<i class="bi bi-instagram"></i>
24+
</a> *@
25+
</div>
26+
</div>
27+
</div>
28+
</div>
29+
</footer>

TestArena/Layout/MainLayout.razor

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
@inherits LayoutComponentBase
2+
@using TestArena.Layout
3+
24
<div class="page">
35
@* <div class="sidebar">
46
<NavMenu/>
@@ -32,5 +34,6 @@
3234
<article class="content px-4">
3335
@Body
3436
</article>
37+
<FooterComponent/>
3538
</main>
3639
</div>

TestArena/wwwroot/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
<head>
55
<meta charset="utf-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>TestArena</title>
7+
<title>Dev Arena</title>
88
<base href="/" />
99
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
1010
<link rel="stylesheet" href="css/app.css" />
11+
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.5.0/font/bootstrap-icons.min.css" rel="stylesheet">
12+
</head>
1113
<link rel="icon" type="image/png" href="favicon.png" />
1214
<link href="TestArena.styles.css" rel="stylesheet" />
1315
</head>

0 commit comments

Comments
 (0)