안녕하세요, Unity IoC 컨테이너 및 Moq를 사용하면서 단위 테스트를 수행하기 위해 테스트 프로젝트를 설정하려고합니다.RegisterType 결과가 오류가 발생했습니다.
public static class SetupMockObjects
{
public static IProductRepository GetProductRepository() {
Mock<IProductRepository> productRepository = new Mock<IProductRepository>();
productRepository.Setup(m => m.Products).Returns(new List<Product> {
new Product { Name = "Football" , Price = 25 },
new Product { Name = "Surf board" , Price = 179 },
new Product { Name = "Running shoes" , Price = 95 }
});
return productRepository.Object;
}
}
public static void Initialise()
{
var container = BuildUnityContainer();
DependencyResolver.SetResolver(new UnityDependencyResolver(container));
}
private static IUnityContainer BuildUnityContainer()
{
var container = new UnityContainer();
container.RegisterType<IProductRepository , SetupMockObjects.GetProductRepository()>();
return container;
}
지금 나는이를 생성하지 않으려는 이유만으로 여기 모의 객체를 만드는 오전 :
내가 Unity.This의 유형을 등록 할 때 오류가 받고있는 것으로 보인다 내 코드입니다 데이터 액세스 레이어 그래서 난 그냥 모의 개체를 만드는 것이 쉬울 것이라고 생각.
Error 1 Invalid expression term ','
Error 2 ; expected
Error 3 ; expected
Error 4 Invalid expression term ')'
Error 5 ) expected
내가 올바른 일반적인 매개 변수 REGISTERTYPE를 호출 오전 prety 확신 내가하지 않는 이유 먹으 렴 : 나는이 오류를 얻을 유형을 등록하려고 할 때
문제는 BuildUnityContainer() 메소드 안에 왜 이러한 오류가 던져 졌는지 이해하십시오. 내가 실수 한 부분은 어디입니까?