Пример #1
0
        public async Task GetByIdAsync_Success()
        {
            List <VehicleModel> vehicleModelList = new List <VehicleModel>
            {
                new VehicleModel {
                    Id = 2, MakeId = 1, Name = "X2", Abrv = "x2"
                },
                new VehicleModel {
                    Id = 3, MakeId = 2, Name = "X1", Abrv = "x1"
                }
            };

            modelRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>()))
            .ReturnsAsync((int id) => vehicleModelList.Where(v => v.Id == id).Single());
            var vehicleModelService = new VehicleModelService(modelRepository.Object);
            var result = await vehicleModelService.GetByIdAsync(2);

            result.ShouldBeEquivalentTo(vehicleModelList.First());
        }