Skip to content

Commit eb222cc

Browse files
committed
Added unit test
1 parent 404f52d commit eb222cc

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

DigitalLearningSolutions.Data.Tests/DataServices/CentresDataServiceTests.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,49 @@ public void UpdateCentreManagerDetails_updates_centre()
184184
}
185185
}
186186

187+
[Test]
188+
public void AddCentre_inserts_new_centre()
189+
{
190+
using var transaction = new TransactionScope();
191+
try
192+
{
193+
// Given
194+
const string centreName = "TestCentre";
195+
const string contactFirstName = "TestFirstName";
196+
const string contactLastName = "TestLastName";
197+
const string contactEmail = "[email protected]";
198+
const string contactTelephone = "0123456789";
199+
const string registrationEmail = "[email protected]";
200+
201+
// When
202+
int insertedID = centresDataService.AddCentreForSuperAdmin(centreName, contactFirstName, contactLastName,
203+
contactEmail, contactTelephone, 1, 1, registrationEmail, "194.176.105", true,true);
204+
var insertedCentre = centresDataService.GetCentreDetailsById(insertedID)!;
205+
206+
// Then
207+
using (new AssertionScope())
208+
{
209+
insertedCentre.CentreName.Should().BeEquivalentTo(centreName);
210+
insertedCentre.ContactForename.Should().BeEquivalentTo(contactFirstName);
211+
insertedCentre.ContactSurname.Should().BeEquivalentTo(contactLastName);
212+
insertedCentre.ContactEmail.Should().BeEquivalentTo(contactEmail);
213+
insertedCentre.ContactTelephone.Should().BeEquivalentTo(contactTelephone);
214+
insertedCentre.CentreType.Should().BeEquivalentTo("NHS Organisation");
215+
insertedCentre.RegionName.Should().BeEquivalentTo("East Midlands");
216+
insertedCentre.RegistrationEmail.Should().BeEquivalentTo(registrationEmail);
217+
insertedCentre.ShowOnMap.Should().Be(true);
218+
insertedCentre.IpPrefix.Should().BeEquivalentTo("194.176.105");
219+
insertedCentre.CmsAdministratorSpots.Should().Be(5);
220+
insertedCentre.ContractType.Should().BeEquivalentTo("Basic");
221+
insertedCentre.TrainerSpots.Should().Be(0);
222+
}
223+
}
224+
finally
225+
{
226+
transaction.Dispose();
227+
}
228+
}
229+
187230
[Test]
188231
public void UpdateCentreWebsiteDetails_updates_centre()
189232
{

DigitalLearningSolutions.Data/DataServices/CentresDataService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ FROM Centres AS c
239239
c.ServerSpaceBytes,
240240
c.CentreTypeID,
241241
ctp.CentreType,
242-
c.ShowOnMap
242+
c.pwEmail as RegistrationEmail
243243
FROM Centres AS c
244244
INNER JOIN Regions AS r ON r.RegionID = c.RegionID
245245
INNER JOIN ContractTypes AS ct ON ct.ContractTypeID = c.ContractTypeId

0 commit comments

Comments
 (0)