Example #1
0
        public async Task <VehicleMake> GetAsync(int id)
        {
            //var getItem = repository.repository.context.VehicleMakes.FirstOrDefault(m => m.Id == id);
            //return mapper.Map<VehicleMake>(await repository.GetAsync(getItem.Id));

            //var getItem = repository.GetAsync(id);
            return(mapper.Map <VehicleMake>(await repository.GetAsync(id)));
        }
        public void GetAsync_Returns_IVehicleMake()
        {
            var dbContextMock = new Mock <DatabaseContext>();
            var dbSetMock     = new Mock <DbSet <VehicleMake> >();

            dbSetMock.Setup(s => s.FindAsync(It.IsAny <Guid>())).Returns(new ValueTask <VehicleMake>(new VehicleMake()));
            dbContextMock.Setup(s => s.Set <VehicleMake>()).Returns(dbSetMock.Object);


            var repository = new VehicleMakeRepository(dbContextMock.Object, mapper);
            var make       = repository.GetAsync(Guid.NewGuid());

            //Assert
            Assert.NotNull(make);
            Assert.IsAssignableFrom <Task <IVehicleMake> >(make);
        }
 public async Task <IVehicleMake> GetAsync(int id)
 {
     return(await repository.GetAsync(id));
 }