public void GetAllManufacturersShould_BeCalled_IfParamsAreValid() { var mockedRepository = new Mock <IRepository <Manufacturer> >(); var manufacturerService = new ManufacturerServices(mockedRepository.Object); manufacturerService.GetAllManufacturers(); mockedRepository.Verify(rep => rep.All(), Times.Once); }
public void GetAllManufacturers_Should_ThrowArgumentNullException_IfPassedManufacturersAreNull() { var mockedRepository = new Mock <IRepository <Manufacturer> >(); var manufacturerService = new ManufacturerServices(mockedRepository.Object); IEnumerable <Manufacturer> expectedManufacturerResult = null; mockedRepository.Setup(rep => rep.All()).Returns(() => expectedManufacturerResult.AsQueryable()); Assert.Throws <ArgumentNullException>(() => manufacturerService.GetAllManufacturers()); }
public void GetAllManufacturers_Should_ReturnEmptyCollection_IfThereAreNoManufacturersAdded() { var mockedRepository = new Mock <IRepository <Manufacturer> >(); var manufacturerService = new ManufacturerServices(mockedRepository.Object); IEnumerable <Manufacturer> expectedManufacturerResult = new List <Manufacturer>(); mockedRepository.Setup(rep => rep.All()).Returns(() => expectedManufacturerResult.AsQueryable()); Assert.IsEmpty(manufacturerService.GetAllManufacturers()); }
public void GetAllManufacturers_Should_DoItsJobCorrectly_IfCalled() { var mockedRepository = new Mock <IRepository <Manufacturer> >(); var manufacturerService = new ManufacturerServices(mockedRepository.Object); IEnumerable <Manufacturer> expectedManufacturerResult = new List <Manufacturer>() { new Manufacturer(), new Manufacturer() }; mockedRepository.Setup(rep => rep.All()).Returns(() => expectedManufacturerResult.AsQueryable()); Assert.AreEqual(manufacturerService.GetAllManufacturers(), expectedManufacturerResult); }