Skip to content

Commit 0f55b09

Browse files
committed
Prepare tests for generic class with date
1 parent f16cc9b commit 0f55b09

File tree

6 files changed

+71
-1
lines changed

6 files changed

+71
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* eslint-disable */
2+
// tslint:disable
3+
4+
import { DateModel } from "./date-model";
5+
6+
export class GenericResult<T> {
7+
public rows: DateModel[];
8+
9+
public constructor(init: Partial<GenericResult<T>> = undefined) {
10+
Object.assign(this, init);
11+
}
12+
}
13+
14+
// outputid:627408ca-a818-4326-b843-415f5bbfb028

Tests/WebApiController/ClientApp/src/app/date/services/date.service.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { DateModelArrayWrapper } from "../models/date-model-array-wrapper";
77
import { DateModelWrapper } from "../models/date-model-wrapper";
88
import { DateModelWrapperListWrapper } from "../models/date-model-wrapper-list-wrapper";
99
import { DateModelWrapperWithDate } from "../models/date-model-wrapper-with-date";
10+
import { GenericResult } from "../models/generic-result";
1011
import { HttpClient } from "@angular/common/http";
1112
import { Injectable } from "@angular/core";
1213
import { Observable } from "rxjs";
@@ -228,6 +229,22 @@ export class DateService {
228229
return subject;
229230
}
230231

232+
public getGenericWithModel(httpOptions?: {}): Observable<GenericResult<DateModel>> {
233+
let subject = new Subject<GenericResult<DateModel>>();
234+
this.http.get<GenericResult<DateModel>>(this.serviceUrl + "/api/date/getgenericwithmodel", httpOptions).subscribe((result) => {
235+
if (result) {
236+
if (result.rows) {
237+
result.rows.forEach((entry) => {
238+
entry.date = this.convertToDate(entry.date);
239+
});
240+
}
241+
}
242+
subject.next(result);
243+
subject.complete();
244+
}, (error) => subject.error(error));
245+
return subject;
246+
}
247+
231248
public post(date: Date, httpOptions?: {}): Observable<void> {
232249
let subject = new Subject<void>();
233250
this.http.post<void>(this.serviceUrl + "/api/date/post" + "?date=" + this.convertFromDate(date), httpOptions).subscribe(() => {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-disable */
2+
// tslint:disable
3+
4+
export class GenericResult<T> {
5+
public rows: string[];
6+
7+
public constructor(init: Partial<GenericResult<T>> = undefined) {
8+
Object.assign(this, init);
9+
}
10+
}
11+
12+
// outputid:627408ca-a818-4326-b843-415f5bbfb028

Tests/WebApiController/Controllers/DateController.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,14 @@ public DateModelArrayWrapper GetWrappedModelArray()
102102
return new DateModelArrayWrapper();
103103
}
104104

105+
[HttpGet("[action]")]
106+
public GenericResult<DateModel> GetGenericWithModel()
107+
{
108+
return new GenericResult<DateModel>(new List<DateModel> { new DateModel() });
109+
}
110+
105111
[HttpPost("[action]")]
106112
public void Post(DateTime date)
107113
{ }
108114
}
109-
}
115+
}

Tests/WebApiController/Controllers/EdgeCasesController.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Threading;
44
using KY.Generator;
55
using Microsoft.AspNetCore.Mvc;
6+
using WebApiController.Models;
67
using WebApiController.Services;
78

89
namespace WebApiController.Controllers
@@ -51,5 +52,11 @@ public string FromHeader([FromHeader] string headerValue = null, int value = 0)
5152
{
5253
return $"Result: {headerValue} + {value}";
5354
}
55+
56+
[HttpGet("[action]")]
57+
public GenericResult<string> GenericResult(string value1, string value2)
58+
{
59+
return new GenericResult<string>(new List<string> { value1, value2 });
60+
}
5461
}
5562
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections.Generic;
2+
3+
namespace WebApiController.Models
4+
{
5+
public class GenericResult<T>
6+
{
7+
public IEnumerable<T> Rows { get; }
8+
9+
public GenericResult(IEnumerable<T> rows)
10+
{
11+
this.Rows = rows;
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)