-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the contact group related methods of ContactService into a n…
…ew ContactGroupService.
- Loading branch information
Ethan Young
committed
Jan 11, 2014
1 parent
6fd7c5a
commit 510d9d3
Showing
10 changed files
with
135 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace EthanYoung.ContactRepository.ContactGroups | ||
{ | ||
public class ContactGroupService : IContactGroupService | ||
{ | ||
private readonly IContactGroupRepository _contactGroupRepository; | ||
|
||
public ContactGroupService(IContactGroupRepository contactGroupRepository) | ||
{ | ||
_contactGroupRepository = contactGroupRepository; | ||
} | ||
|
||
public void Save(IContactGroup contactGroup) | ||
{ | ||
_contactGroupRepository.Save(contactGroup); | ||
} | ||
|
||
public List<IContactGroup> FindAll() | ||
{ | ||
return _contactGroupRepository.FindAll(); | ||
} | ||
|
||
public IContactGroup FindByIdentifier(Guid identifier) | ||
{ | ||
return _contactGroupRepository.FindByIdentifier(identifier); | ||
} | ||
|
||
public void DeleteByIdentifier(Guid identifier) | ||
{ | ||
_contactGroupRepository.DeleteByIdentifier(identifier); | ||
} | ||
} | ||
|
||
public interface IContactGroupService : IService | ||
{ | ||
void Save(IContactGroup contactGroup); | ||
List<IContactGroup> FindAll(); | ||
IContactGroup FindByIdentifier(Guid identifier); | ||
void DeleteByIdentifier(Guid identifier); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ormCRUDOperationsForContactGroups.feature → ...upServiceCanPerformCRUDOperations.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...CRUDOperationsForContactGroups.feature.cs → ...erviceCanPerformCRUDOperations.feature.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
Source/Tests/AcceptanceTests/ContactGroupService/ContactGroupServiceSteps.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using EthanYoung.ContactRepository.ContactGroups; | ||
using NUnit.Framework; | ||
using TechTalk.SpecFlow; | ||
|
||
namespace EthanYoung.ContactRepository.Tests.AcceptanceTests.ContactGroupService | ||
{ | ||
[Binding] | ||
public class ContactGroupServiceSteps | ||
{ | ||
private readonly IContactGroupService _service = DependencyRegistry.Resolve<IContactGroupService>(); | ||
|
||
private IContactGroup _contactGroup; | ||
private IContactGroup _retrievedContactGroup; | ||
|
||
[BeforeScenario] | ||
public void BeforeScenario() | ||
{ | ||
_contactGroup = null; | ||
_retrievedContactGroup = null; | ||
} | ||
|
||
[Given(@"I create a contact group")] | ||
public void GivenICreateAContactGroup() | ||
{ | ||
_contactGroup = new ContactGroup | ||
{ | ||
Identifier = Guid.NewGuid(), | ||
Name = "My Contacts" | ||
}; | ||
} | ||
|
||
[Given(@"I change the name of the contact group")] | ||
public void GivenIChangeTheNameOfTheContactGroup() | ||
{ | ||
_contactGroup.Name += " Updated"; | ||
} | ||
|
||
[Given(@"I save the contact group")] | ||
public void GivenISaveTheContactGroup() | ||
{ | ||
_service.Save(_contactGroup); | ||
} | ||
|
||
[Given(@"I delete the contact group")] | ||
public void GivenIDeleteTheContactGroup() | ||
{ | ||
_service.DeleteByIdentifier(_contactGroup.Identifier); | ||
} | ||
|
||
[When(@"I retrieve the contact group")] | ||
public void WhenIRetrieveTheContactGroup() | ||
{ | ||
_retrievedContactGroup = _service.FindByIdentifier(_contactGroup.Identifier); | ||
} | ||
|
||
[Then(@"the retrieved contact group is null")] | ||
public void ThenTheRetrievedContactGroupIsNull() | ||
{ | ||
Assert.IsNull(_retrievedContactGroup); | ||
} | ||
|
||
[Then(@"the name of the retrieved contact group is equal to the name of the contact group")] | ||
public void ThenTheNameOfTheRetrievedContactGroupIsEqualToTheNameOfTheContactGroup() | ||
{ | ||
Assert.AreEqual(_contactGroup.Name, _retrievedContactGroup.Name); | ||
} | ||
|
||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...nPerformCRUDOperationsForContacts.feature → ...ctServiceCanPerformCRUDOperations.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...rformCRUDOperationsForContacts.feature.cs → ...erviceCanPerformCRUDOperations.feature.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.