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
[Fact] | |
public void Get_Person_By_Id() | |
{ | |
var person = new Person { BusinessEntityID = 3}; | |
var mockpersonRepository = new Mock(); | |
mockpersonRepository.Setup(x => x.GetPersonById(3)) | |
.Returns(person); //return Person | |
mockpersonRepository.Object.GetPersonById(3).ShouldBe(person); //Assert expected value equal to actual value | |
mockpersonRepository.Verify(x => x.GetPersonById(person.BusinessEntityID), Times.Once()); //Assert that the Get method was called once |
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
public class PersonRepository : GenericRepository<Person>, IPersonRepository | |
{ | |
public PersonRepository(IUnitOfWork uow) : base(uow) | |
{ | |
} | |
public Person GetPersonById(long id) | |
{ | |
return GetById(id); | |
} |
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
[Fact] | |
public void Create_Person_Calls_PersonRepositoryAdd() | |
{ | |
var person = new Person { BusinessEntityID = 3}; | |
var mockpersonRepository = new Mock<IPersonRepository>(); | |
mockpersonRepository.Setup(x => x.Add(person)); //no return as it's a void method | |
mockpersonRepository.Object.Add(person); | |
mockpersonRepository.Verify(x => x.Add(person), Times.Once()); //Assert that the Add method was called once |
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
[Fact] | |
public void Delete_Person_ById() | |
{ | |
var person = new Person {BusinessEntityID = 3}; | |
var mockpersonRepository = new Mock(); | |
mockpersonRepository.Setup(x => x.Delete(person)); | |
mockpersonRepository.Object.Delete(person); //no return as it's a void method |
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
var app = angular.module('testApp',[]).directive('myDirective1',function(){ | |
return{ | |
template:"<div>Hello from directive 1</div>", | |
replace:true, | |
retrict:'E' | |
} | |
}).directive('myDirective2',function(){ | |
return{ | |
template:"<div>Hello from directive 2</div>", | |
replace:true, |
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
<!DOCTYPE html> | |
<html ng-app="testApp" ng-strict-di> | |
<head> | |
<base ref="/"> | |
<meta content="IE=edge, chrome=1" http-equiv="X-UA-Compatible" /> | |
<body ng-controller="HomeController as AppCtrl"> | |
<my-directive1></my-directive1> | |
<my-directive2></my-directive2> |