Пример #1
0
        public void Call_AllMethodFromRepositoryOnce()
        {
            // Arrange
            var expectedBrandId     = Guid.NewGuid();
            var randomRandomBrandId = Guid.NewGuid();

            var carModels = new List <CarModel>
            {
                new CarModel {
                    Model = "A99", CarBrandId = expectedBrandId
                },
                new CarModel {
                    Model = "Y6", CarBrandId = expectedBrandId
                },
                new CarModel {
                    Model = "Ugly", CarBrandId = randomRandomBrandId
                },
                new CarModel {
                    Model = "A3", CarBrandId = randomRandomBrandId
                },
            }.AsQueryable();

            carModelsRepoMocked.Setup(x => x.All).Returns(carModels);

            var carModelsServices = new CarModelServices(this.carModelsRepoMocked.Object);

            // Act
            carModelsServices.GetAllModelsByBrand(expectedBrandId);

            // Assert
            this.carModelsRepoMocked.Verify(x => x.All, Times.Once);
        }
Пример #2
0
        public void ReturnCarModelObject_WithExactPassedId()
        {
            // Arrange
            var expectedBrandId     = Guid.NewGuid();
            var randomRandomBrandId = Guid.NewGuid();

            var carModels = new List <CarModel>
            {
                new CarModel {
                    Model = "A99", CarBrandId = expectedBrandId
                },
                new CarModel {
                    Model = "Y6", CarBrandId = expectedBrandId
                },
                new CarModel {
                    Model = "Ugly", CarBrandId = randomRandomBrandId
                },
                new CarModel {
                    Model = "A3", CarBrandId = randomRandomBrandId
                },
            }.AsQueryable();

            carModelsRepoMocked.Setup(x => x.All).Returns(carModels);

            var carModelsServices = new CarModelServices(this.carModelsRepoMocked.Object);

            // Act
            var carModelsFromExecution = carModelsServices.GetAllModelsByBrand(expectedBrandId);

            // Assert
            Assert.AreEqual(2, carModelsFromExecution.Count());
        }
Пример #3
0
        public void ReturnInstanceOfEnumerable_WithValidaDataIsPassed()
        {
            // Arrange
            var carModelsServices = new CarModelServices(this.carModelsRepoMocked.Object);

            // Act
            var allCarModelsResult = carModelsServices.GetAllModelsByBrand(It.IsAny <Guid>());

            // Assert
            Assert.IsInstanceOf <IEnumerable <CarModel> >(allCarModelsResult);
        }