Exemple #1
0
 public void RegisterTest()
 {
     using (var mock = AutoMock.GetLoose())
     {
         var rebeld = new Rebeld();
         mock.Mock <IInfrastructureRepository <Rebeld> >().Setup(repository => repository.Register(rebeld)).Returns(rebeld);
         mock.Mock <ILog>();
         var mockedService = mock.Create <IInfrastructureRepository <Rebeld> >();
         var mockedLog     = mock.Create <ILog>();
         var rebeldService = new RebeldService(mockedLog, mockedService);
         var rebeldDto     = new RebeldDto();
         rebeldDto.Names = new List <String>()
         {
             ("Pepe")
         };
         rebeldDto.PlanetName = "Saturno";
         var result = rebeldService.Register(rebeldDto);
         Assert.AreEqual(true, result);
     }
 }
Exemple #2
0
 public void RegisterTest1()
 {
     using (var mock = AutoMock.GetLoose())
     {
         var rebeldDto = new RebeldDto
         {
             Names = new List <String>()
             {
                 ("Pepe")
             },
             PlanetName = "Saturno"
         };
         mock.Mock <IService <RebeldDto> >().Setup(repository => repository.Register(rebeldDto)).Returns(true);
         mock.Mock <ILog>();
         var mockedService        = mock.Create <IService <RebeldDto> >();
         var mockedLog            = mock.Create <ILog>();
         var controller           = new RebeldController(mockedLog, mockedService);
         IHttpActionResult result = controller.Register(rebeldDto);
         var response             = result as OkNegotiatedContentResult <RebeldDto>;
         Assert.IsNotNull(response.Content);
     }
 }