/
GetCustomersListSteps.cs
51 lines (42 loc) · 1.4 KB
/
GetCustomersListSteps.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Linq;
using CleanArchitecture.Application.Customers.Queries.GetCustomerList;
using CleanArchitecture.Specification.Common;
using NUnit.Framework;
using TechTalk.SpecFlow;
using TechTalk.SpecFlow.Assist;
namespace CleanArchitecture.Specification.Customers.GetCustomersList
{
[Binding]
public class GetCustomersListSteps
{
private readonly AppContext _context;
private List<CustomerModel> _results;
public GetCustomersListSteps(AppContext context)
{
_context = context;
}
[When(@"I request a list of customers")]
public void WhenIRequestAListOfCustomers()
{
var query = _context.Container
.GetInstance<GetCustomersListQuery>();
_results = query.Execute();
}
[Then(@"the following customers should be returned:")]
public void ThenTheFollowingCustomersShouldBeReturned(Table table)
{
var models = table.CreateSet<CustomerModel>().ToList();
for (var i = 0; i < models.Count(); i++)
{
var model = models[i];
var result = _results[i];
Assert.That(result.Id,
Is.EqualTo(model.Id));
Assert.That(result.Name,
Is.EqualTo(model.Name));
}
}
}
}