예제 #1
0
 public IEnumerable <Make> GetMakes()
 {
     return(makeRepository.Get().Select(model => new Make()
     {
         Id = model.Id,
         Name = model.Name
     }));
 }
예제 #2
0
        public async Task <IVehicleMakeDomain> Read(Guid id)
        {
            //Get maker
            var response = await MakeRepository.Get(id);

            //Get his models
            var models = await ModelRepository.GetMakersModels(response.VehicleMakeId);

            //Inject them
            response.VehicleModel = models;

            return(response);
        }
예제 #3
0
        public void MakeRepositoryGetTest()
        {
            //Arrange
            IncludeAllMappings.include();
            var vMake = new VehicleMakeDomain()
            {
                Name = "MakeRepositoryGetTest", Abrv = "MakeRepositoryGetTest", VehicleModel = null
            };
            var context        = new VehicleContext();
            var repository     = new Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context)));
            var testRepository = new MakeRepository(repository);
            int response;

            Task.Run(async() =>
            {
                response = await testRepository.Add(vMake);
                //Assert.AreEqual(1, response);
            }).GetAwaiter().GetResult();

            IEnumerable <IVehicleMakeDomain> getAll;
            IVehicleMakeDomain targetMake = null;

            Task.Run(async() =>
            {
                getAll = await testRepository.GetAll();
                //Assert
                Assert.IsNotNull(getAll);

                foreach (var item in getAll)
                {
                    targetMake = item;
                }

                var result = await testRepository.Get(targetMake.VehicleMakeId);
                //Assert
                Assert.AreEqual(targetMake.VehicleMakeId, result.VehicleMakeId);
            }).GetAwaiter().GetResult();
        }
예제 #4
0
        public void CanGetMake()
        {
            var repo = new MakeRepository();

            Assert.AreEqual("Jeep", repo.Get(1).MakeName);
        }