public void GetNucleosPaged_Success_Test() { // Arrange string searchTerm = ""; int pageIndex = 0; int pageSize = 10; // list IList <R_Nucleo> list = new List <R_Nucleo>(); for (int i = 1; i <= pageSize; i++) { list.Add(SampleNucleo(i)); } // create mock for repository var mock = new Mock <INucleoRepository>(); mock.Setup(s => s.GetNucleos(Moq.It.IsAny <string>(), Moq.It.IsAny <int>(), Moq.It.IsAny <int>())).Returns(list); // service NucleoService nucleoService = new NucleoService(); NucleoService.Repository = mock.Object; // Act var resultList = nucleoService.GetNucleos(searchTerm, pageIndex, pageSize); NucleoDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.NucleoId); Assert.AreEqual(10, resultList.Count); }
public void GetNucleos_Success_Test() { // Arrange R_Nucleo nucleo = SampleNucleo(1); IList <R_Nucleo> list = new List <R_Nucleo>(); list.Add(nucleo); // create mock for repository var mock = new Mock <INucleoRepository>(); mock.Setup(s => s.GetNucleos()).Returns(list); // service NucleoService nucleoService = new NucleoService(); NucleoService.Repository = mock.Object; // Act var resultList = nucleoService.GetNucleos(); NucleoDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.NucleoId); }
public void DeleteNucleoById_Success_Test() { // Arrange int id = 1; // create mock for repository var mock = new Mock <INucleoRepository>(); mock.Setup(s => s.DeleteNucleo(Moq.It.IsAny <int>())).Verifiable(); // service NucleoService nucleoService = new NucleoService(); NucleoService.Repository = mock.Object; // Act nucleoService.DeleteNucleo(id); // Assert Assert.IsTrue(true); }
public void UpdateNucleo_Success_Test() { // Arrange NucleoDTO dto = SampleNucleoDTO(1); // create mock for repository var mock = new Mock <INucleoRepository>(); mock.Setup(s => s.UpdateNucleo(Moq.It.IsAny <R_Nucleo>())).Verifiable(); // service NucleoService nucleoService = new NucleoService(); NucleoService.Repository = mock.Object; // Act nucleoService.UpdateNucleo(dto); // Assert Assert.IsNotNull(dto); }
public void AddNucleo_Success_Test() { // Arrange NucleoDTO dto = SampleNucleoDTO(1); // create mock for repository var mock = new Mock <INucleoRepository>(); mock.Setup(s => s.AddNucleo(Moq.It.IsAny <R_Nucleo>())).Returns(1); // service NucleoService nucleoService = new NucleoService(); NucleoService.Repository = mock.Object; // Act int id = nucleoService.AddNucleo(dto); // Assert Assert.AreEqual(1, id); Assert.AreEqual(1, dto.NucleoId); }
public void GetNucleo_Success_Test() { // Arrange int id = 1; R_Nucleo nucleo = SampleNucleo(id); // create mock for repository var mock = new Mock <INucleoRepository>(); mock.Setup(s => s.GetNucleo(Moq.It.IsAny <int>())).Returns(nucleo); // service NucleoService nucleoService = new NucleoService(); NucleoService.Repository = mock.Object; // Act NucleoDTO result = nucleoService.GetNucleo(id); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.NucleoId); }
public void GetNucleoListAdvancedSearch_Success_Test() { // Arrange string name = null; string personResponsible = null; int? photo = null; int? addressId = null; System.DateTime?openingDateFrom = null; System.DateTime?openingDateTo = null; string primaryPhoneNumber = null; string primaryEmail = null; bool? active = null; //int pageIndex = 0; int pageSize = 10; // list IList <R_Nucleo> list = new List <R_Nucleo>(); for (int i = 1; i <= pageSize; i++) { list.Add(SampleNucleo(i)); } // create mock for repository var mock = new Mock <INucleoRepository>(); mock.Setup(s => s.GetNucleoListAdvancedSearch( Moq.It.IsAny <string>() // name , Moq.It.IsAny <string>() // personResponsible , Moq.It.IsAny <int?>() // photo , Moq.It.IsAny <int?>() // addressId , Moq.It.IsAny <System.DateTime?>() // openingDateFrom , Moq.It.IsAny <System.DateTime?>() // openingDateTo , Moq.It.IsAny <string>() // primaryPhoneNumber , Moq.It.IsAny <string>() // primaryEmail , Moq.It.IsAny <bool?>() // active )).Returns(list); // service NucleoService nucleoService = new NucleoService(); NucleoService.Repository = mock.Object; // Act var resultList = nucleoService.GetNucleoListAdvancedSearch( name , personResponsible , photo , addressId , openingDateFrom , openingDateTo , primaryPhoneNumber , primaryEmail , active ); NucleoDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.NucleoId); }