-
Notifications
You must be signed in to change notification settings - Fork 3
/
DeleteICControllerTests.cs
50 lines (43 loc) · 1.79 KB
/
DeleteICControllerTests.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
using System.Linq;
using System.Net;
using ControllerTests.Web;
using ControllerTests.Web.Models;
using NHibernate;
using NHibernate.Linq;
using Shouldly;
using Xunit;
namespace ControllerTests.Tests
{
public class DeleteIcControllerTests : ApiControllerTestBase<ISession>
{
public DeleteIcControllerTests() : base(new ApiTestSetup<ISession>(HomeControllerTests.MssqlTestSetup, WebApiConfig.Register)) { }
[Fact]
public void GivenOneIC_WhenRemoveOnlyIC_ThenStoreShouldBeEmpty()
{
var ic = new IntegratedCircuit { Code = "1", Description = "Test1" };
Session.Save(ic);
Session.Flush();
var result = Post("/api/deleteic/" + ic.Id, new { }, useHttps: true);
result.StatusCode.ShouldBe(HttpStatusCode.OK);
Session.Query<IntegratedCircuit>().ShouldBeEmpty();
}
[Fact]
public void GivenASetOfICs_WhenRemovingASpecificOne_ThenOnlyThatOneIsMissing()
{
new[]
{
new IntegratedCircuit {Code = "1", Description = "Test1"},
new IntegratedCircuit {Code = "2", Description = "Test2"},
new IntegratedCircuit {Code = "3", Description = "Test3"},
}.ForEach(ic => Session.Save(ic));
Session.Flush();
var ic2 = Session.Query<IntegratedCircuit>().Single(i => i.Code == "2");
var result = Post("/api/deleteic/" + ic2.Id, new { }, useHttps: true);
result.StatusCode.ShouldBe(HttpStatusCode.OK);
var allRemainingICs = Session.Query<IntegratedCircuit>().ToList();
allRemainingICs.Count().ShouldBe(2);
allRemainingICs[0].Description.ShouldBe("Test1");
allRemainingICs[1].Description.ShouldBe("Test3");
}
}
}