private List <SelectListItem> GetFuelType()
        {
            FuelTypeFilter filter = new FuelTypeFilter();

            filter.Name = "";
            return(FuelTypeService.Get(filter).Select(b => new SelectListItem(b.Name, b.Id.ToString())).ToList());
        }
Esempio n. 2
0
        public UnitTest(ITestOutputHelper output)
        {
            options = new DbContextOptionsBuilder <GasolineContext>()
                      .UseInMemoryDatabase("Test")
                      .Options;

            fuelTypeService = new FuelTypeService(new GasolineContext(options));
        }
Esempio n. 3
0
        public async Task Test2()
        {
            using (var context = new GasolineContext(options))
            {
                var service = new FuelTypeService(context);
                IEnumerable <FuelType> result = await service.BrowseAsync();

                // Check if FuelType was added
                Assert.Single(result.ToList());
            }
        }
Esempio n. 4
0
        public async Task Test4()
        {
            using (var context = new GasolineContext(options))
            {
                var service = new FuelTypeService(context);
                var x       = await service.RemoveAsync(Guid.Parse("74d5aaf9-f5f1-45fe-bc79-1ab94eddb806"));

                var result = await service.BrowseAsync();

                Assert.Empty(result.ToList());
            }
        }
        public async Task GetAllTypesAsyncShouldReturnEmptyCollectionIfNoFuelTypes()
        {
            //Arrange
            var repository      = this.GetFuelTypeRepository(new List <FuelType>());
            var fuelTypeService = new FuelTypeService(repository.Object);

            //Act
            var result = await fuelTypeService.GetAllTypesAsync();

            //Assert
            result
            .Should()
            .BeEmpty();
        }
        public async Task GetAllTypesAsyncShouldReturnCollectionOfFuelTypesIfAny()
        {
            //Arrange
            var repository      = this.GetFuelTypeRepository(this.GetTestFuelTypeList());
            var fuelTypeService = new FuelTypeService(repository.Object);

            //Act
            var result = await fuelTypeService.GetAllTypesAsync();

            //Assert
            result
            .Should()
            .NotBeEmpty();
        }
Esempio n. 7
0
        public async Task Test3()
        {
            using (var context = new GasolineContext(options))
            {
                var service = new FuelTypeService(context);
                await service.AddAsync(new Data.Models.FuelType {
                    Id = Guid.Parse("74d5aaf9-f5f1-45fe-bc79-1ab94eddb806"), FuelName = "Benzyna 95"
                });

                IEnumerable <FuelType> result = await service.BrowseByNameAsync("Benzyna");

                Assert.Single(result.ToList());
            }
        }
Esempio n. 8
0
        public async Task Test1()
        {
            using (var context = new GasolineContext(options))
            {
                var x = await context.AddAsync(new Data.Models.FuelType {
                    Id = Guid.Parse("74d5aaf9-f5f1-45fe-bc79-1ab94eddb806"), FuelName = "Benzyna 95"
                });

                await context.SaveChangesAsync();
            }

            using (var context = new GasolineContext(options))
            {
                var service = new FuelTypeService(context);
                IEnumerable <FuelType> result = await service.BrowseAsync();

                // Check if FuelType was added
                Assert.Single(result.ToList());
            }
        }
 public FuelTypesController(FuelTypeService fuelTypeService)
 {
     _fuelTypeService = fuelTypeService;
 }
Esempio n. 10
0
 private List <SelectListItem> GetFuelTypes()
 {
     return(FuelTypeService.Get(new FuelTypeFilter()).Select(f => new SelectListItem(f.Name, f.Id.ToString())).ToList());
 }