Exemplo n.º 1
0
        public void GetAllVehicleModels_Should_BeCalled_IfParamsAreValid()
        {
            // Arrange
            var mockedDbSet         = new Mock <IEfCarSystemDbSetCocoon <VehicleModel> >();
            var vehicleModelService = new VehicleModelService(mockedDbSet.Object);

            // Act
            vehicleModelService.GetAllVehicleModels();

            // Assert
            mockedDbSet.Verify(rep => rep.All(), Times.Once);
        }
Exemplo n.º 2
0
        public void GetAllVehicleModels_Should_ThrowArgumentNullException_IfPassedVehicleModelsAreNull()
        {
            // Arrange
            var mockedDbSet         = new Mock <IEfCarSystemDbSetCocoon <VehicleModel> >();
            var vehicleModelService = new VehicleModelService(mockedDbSet.Object);

            // Act
            IEnumerable <VehicleModel> expectedVehicleModelsResult = null;

            mockedDbSet.Setup(rep => rep.All()).Returns(() => expectedVehicleModelsResult.AsQueryable());

            // Assert
            Assert.Throws <ArgumentNullException>(() => vehicleModelService.GetAllVehicleModels());
        }
Exemplo n.º 3
0
        public void GetAllVehicleModels_Should_ReturnEmptyCollection_IfThereAreNoVehicleModelsAdded()
        {
            // Arrange
            var mockedDbSet         = new Mock <IEfCarSystemDbSetCocoon <VehicleModel> >();
            var vehicleModelService = new VehicleModelService(mockedDbSet.Object);

            // Act
            IEnumerable <VehicleModel> expectedVehicleModelsResult = new List <VehicleModel>();

            mockedDbSet.Setup(rep => rep.All()).Returns(() => expectedVehicleModelsResult.AsQueryable());

            // Assert
            Assert.IsEmpty(vehicleModelService.GetAllVehicleModels());
        }
Exemplo n.º 4
0
        public void GetAllVehicleModels_Should_ReturnCorrectCollection_IfCalled()
        {
            // Arrange
            var mockedDbSet         = new Mock <IEfCarSystemDbSetCocoon <VehicleModel> >();
            var vehicleModelService = new VehicleModelService(mockedDbSet.Object);

            // Act
            IEnumerable <VehicleModel> expectedVehicleModelsResult = new List <VehicleModel>()
            {
                new VehicleModel(), new VehicleModel()
            };

            mockedDbSet.Setup(rep => rep.All()).Returns(() => expectedVehicleModelsResult.AsQueryable());

            // Assert
            Assert.AreEqual(vehicleModelService.GetAllVehicleModels(), expectedVehicleModelsResult);
        }