Exemple #1
0
        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);
        }
Exemple #2
0
        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());
        }
Exemple #3
0
        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());
        }
Exemple #4
0
        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);
        }