-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
187 additions
and
9 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ClassDiagram MajorVersion="1" MinorVersion="1" MembersFormat="FullSignature"> | ||
<Class Name="DogLibraryCore.MammalRepoSimple"> | ||
<Position X="3.75" Y="1" Width="4.75" /> | ||
<TypeIdentifier> | ||
<HashCode>AAIAAAAAAAAAAAAIAAAABAIAAAAAAAAAAAAAAACAAAA=</HashCode> | ||
<FileName>Repo\MammalRepoSimple.cs</FileName> | ||
</TypeIdentifier> | ||
</Class> | ||
<Class Name="DogLibraryCore.EntityBase"> | ||
<Position X="9.5" Y="2" Width="1.5" /> | ||
<TypeIdentifier> | ||
<HashCode>AAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> | ||
<FileName>Repo\IEntity.cs</FileName> | ||
</TypeIdentifier> | ||
<Lollipop Position="0.2" /> | ||
</Class> | ||
<Class Name="DogLibraryCore.Repository<T>"> | ||
<Position X="9.5" Y="3.5" Width="2.75" /> | ||
<TypeIdentifier> | ||
<HashCode>AAIAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAII=</HashCode> | ||
<FileName>Repo\Repository.cs</FileName> | ||
</TypeIdentifier> | ||
<Lollipop Position="0.2" /> | ||
</Class> | ||
<Class Name="DogLibraryCore.Repo.MammalRepo"> | ||
<Position X="12.5" Y="3.5" Width="4.25" /> | ||
<TypeIdentifier> | ||
<HashCode>AAAAAAAAAIACAAAAAAAAQAAAAACAAAAAAAAAAAAAQAA=</HashCode> | ||
<FileName>Repo\MammalRepo.cs</FileName> | ||
</TypeIdentifier> | ||
<Lollipop Position="0.2" /> | ||
</Class> | ||
<Interface Name="DogLibraryCore.IRepository<T>"> | ||
<Position X="11.5" Y="0.5" Width="2.5" /> | ||
<TypeIdentifier> | ||
<HashCode>AAIAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAII=</HashCode> | ||
<FileName>Repo\IRepository.cs</FileName> | ||
</TypeIdentifier> | ||
</Interface> | ||
<Interface Name="DogLibraryCore.IEntity"> | ||
<Position X="9.5" Y="0.5" Width="1.5" /> | ||
<TypeIdentifier> | ||
<HashCode>AAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> | ||
<FileName>Repo\IEntity.cs</FileName> | ||
</TypeIdentifier> | ||
</Interface> | ||
<Font Name="Segoe UI" Size="9" /> | ||
</ClassDiagram> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using DogLibrary; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Linq; | ||
|
||
namespace DogLibraryCore.Repo | ||
{ | ||
public class MammalRepo : IRepository<IMammal> | ||
{ | ||
|
||
List<IMammal> _repo; | ||
|
||
public MammalRepo() : base() | ||
{ | ||
_repo = new List<IMammal>(); | ||
} | ||
|
||
void IRepository<IMammal>.Add(IMammal entity) | ||
{ | ||
this._repo.Add(entity); | ||
} | ||
|
||
IMammal IRepository<IMammal>.GetById(int id) | ||
{ | ||
return this._repo.Where<IMammal>(m => m.Id == id).FirstOrDefault(); | ||
} | ||
|
||
IEnumerable<IMammal> IRepository<IMammal>.List() | ||
{ | ||
return this._repo; | ||
} | ||
|
||
void IRepository<IMammal>.Remove(IMammal entity) | ||
{ | ||
this._repo.Remove(entity); | ||
} | ||
|
||
|
||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,6 @@ public void Remove(T entity) | |
_repo.Add(entity); | ||
|
||
} | ||
public void Update(T entity) | ||
{ | ||
|
||
} | ||
|
||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
DogLibraryCore/UnitTestProjectDogMoq/MammalSimpleRepoTests.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,79 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using DogLibrary; | ||
using DogLibraryCore; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace UnitTestProjectDogMoq | ||
{ | ||
[TestClass] | ||
class MammalSimpleRepoTests | ||
{ | ||
|
||
[TestClass] | ||
public class MammalSimpleRepoTest | ||
{ | ||
[TestMethod] | ||
public void TestFindByName() | ||
{ | ||
//Arrange | ||
string findName = "fido"; | ||
int findWeight = 20; | ||
Dog foundByName, foundByWeight; | ||
|
||
MammalRepoSimple repo = new MammalRepoSimple(); | ||
repo.Add(new Dog() { Name = findName, Weight = 10 }); | ||
repo.Add(new Dog() { Name = "milo", Weight = findWeight }); | ||
//act | ||
foundByName = repo.GetMammalByName(findName) as Dog; | ||
foundByWeight = repo.GetMammalByWeight(findWeight) as Dog; | ||
|
||
//assert | ||
Assert.AreEqual(findName, foundByName.Name); | ||
Assert.AreEqual(findWeight, foundByWeight.Weight); | ||
} | ||
|
||
[TestMethod] | ||
public void TestFindByNameReturnsNullIfNotFound() | ||
{ | ||
//Arrange | ||
string findName = "jeff"; | ||
int findWeight = 20; | ||
Dog foundByName; | ||
|
||
MammalRepoSimple repo = new MammalRepoSimple(); | ||
repo.Add(new Dog() { Name = "fido", Weight = 10 }); | ||
repo.Add(new Dog() { Name = "milo", Weight = findWeight }); | ||
//act | ||
foundByName = repo.GetMammalByName(findName) as Dog; | ||
|
||
|
||
//assert | ||
Assert.IsNull(foundByName); | ||
|
||
} | ||
|
||
[TestMethod] | ||
public void TestFindByWeightReturnsNullIfNotFound() | ||
{ | ||
//Arrange | ||
|
||
int findWeight = 22; | ||
Dog foundByWeight; | ||
|
||
MammalRepoSimple repo = new MammalRepoSimple(); | ||
repo.Add(new Dog() { Name = "fido", Weight = 10 }); | ||
repo.Add(new Dog() { Name = "milo", Weight = 20 }); | ||
//act | ||
foundByWeight = repo.GetMammalByWeight(findWeight) as Dog; | ||
|
||
|
||
//assert | ||
Assert.IsNull(foundByWeight); | ||
|
||
} | ||
} | ||
|
||
} | ||
} |