public TankDistributorController(AppDbContext context, TankDistributorService tankDistributorService, TankService tankService, DistributorService distributorService)
 {
     _context = context;
     _tankDistributorService = tankDistributorService;
     _tankService            = tankService;
     _distributorService     = distributorService;
 }
            public void WhenPassingCorrectData_CreateSuccessfully(string name, int volume)
            {
                using (var dbContextFactory = new SqlLiteDbContextFactory())
                {
                    // Run the test against the instance of the context
                    using (var context = dbContextFactory.CreateContext())
                    {
                        var service = new TankService(context);
                        var tank    = InstantiateTank(name, volume);
                        service.Create(tank);
                    }

                    // Get another context using the same connection
                    using (var context = dbContextFactory.CreateContext())
                    {
                        var service = new TankService(context);
                        var tanks   = service.FindAll();
                        Assert.Equal(1, tanks.Count);
                        var tank = tanks.First();
                        Assert.NotNull(tank);
                        // TODO: uncomment below after fix and investigate why the navigation property 'Equipment' is not eager loaded
                        // AssertTank(tank, null, name, volume);
                    }
                }
            }
 public DistributorController(AppDbContext context, DistributorService distributorService, ProductService productService, TankService tankService)
 {
     _context            = context;
     _distributorService = distributorService;
     _productService     = productService;
     _tankService        = tankService;
 }
        /// <summary>
        /// Konstruktor
        /// </summary>
        public AdminArea()
        {
            InitializeComponent();
            List <IAdminMessage> messages = new List <IAdminMessage>();

            foreach (Tank tank in GasStation.GetInstance().TankList)
            {
                //Schaut ob genĂ¼gend Treibstoff im Tank ist
                if (!TankService.HasEnoughInTank(tank))
                {
                    IAdminMessage message = new AdminMessage();
                    message.Status      = MessageStatus.Warning;
                    message.Description = "Das Tank minimum wurde im Tank " + tank.Name + " erreicht";
                    messages.Add(message);
                }

                //Vergleicht mit dem letzten Jahr und schaut ob genĂ¼gend Treibstoff im Tank ist
                if (TankService.AdjustTankMinimum(tank))
                {
                    IAdminMessage message = new AdminMessage();
                    message.Status      = MessageStatus.Warning;
                    message.Description = "Letztes Jahr wurde im Tank: " + tank.Name + " der Treibstoff sehr knapp";
                    messages.Add(message);
                }
            }

            messageList.ItemsSource = messages;
        }
 public void WhenTankNotExists_ShouldThrowException(int id)
 {
     using (var factory = new SqlLiteDbContextFactory())
     {
         using (var context = factory.CreateContext())
         {
             var service = new TankService(context);
             Assert.Throws <Exception>(() => service.Delete(id));
         }
     }
 }
            public void WhenTankDoesNotExists_ReturnNone()
            {
                using (var factory = new SqlLiteDbContextFactory())
                {
                    using (var context = factory.CreateContext())
                    {
                        var service = new TankService(context);
                        var tanks   = service.FindAll();

                        Assert.Empty(tanks);
                    }
                }
            }
            public void WhenTankDoesNotExist_ReturnNull(int id)
            {
                using (var factory = new SqlLiteDbContextFactory())
                {
                    using (var context = factory.CreateContext())
                    {
                        SetupTestData(context);

                        var service = new TankService(context);
                        var tank    = service.FindById(id);
                        Assert.Null(tank);
                    }
                }
            }
            public void WhenTankExists_ReturnTank(int id, string name, int volume)
            {
                using (var factory = new SqlLiteDbContextFactory())
                {
                    using (var context = factory.CreateContext())
                    {
                        SetupTestData(context);

                        var service = new TankService(context);
                        var tank    = service.FindById(id);

                        AssertTank(tank, id, name, volume);
                    }
                }
            }
            public void WhenTankExists_ReturnAll()
            {
                using (var factory = new SqlLiteDbContextFactory())
                {
                    using (var context = factory.CreateContext())
                    {
                        SetupTestData(context);

                        var service = new TankService(context);
                        var tanks   = service.FindAll();

                        Assert.Equal(2, tanks.Count);
                    }
                }
            }
            public void WhenTankDoesNotExist_ShouldThrowException(int id, string name, int volume)
            {
                using (var factory = new SqlLiteDbContextFactory())
                {
                    using (var context = factory.CreateContext())
                    {
                        SetupTestData(context);

                        var service = new TankService(context);
                        var tank    = InstantiateTank(id, name, volume);

                        Assert.Throws <Exception>(() => service.Update(tank));
                    }
                }
            }
            public void WhenTankExists_ShouldDeleteTank(int id)
            {
                using (var factory = new SqlLiteDbContextFactory())
                {
                    using (var context = factory.CreateContext())
                    {
                        SetupTestData(context);

                        var service = new TankService(context);
                        service.Delete(id);

                        var tank = service.FindById(id);
                        Assert.Null(tank);
                    }
                }
            }
 public TransactionController(TransactionService transactionService,
                              AccountService accountService,
                              LoyaltyCardService loyaltyCardService,
                              ProductService productService,
                              ProductsListService productsListService,
                              DistributorService distributorService,
                              TankService tankService,
                              DiscountService discountService)
 {
     _transactionService  = transactionService;
     _accountService      = accountService;
     _loyaltyCardService  = loyaltyCardService;
     _productService      = productService;
     _productsListService = productsListService;
     _distributorService  = distributorService;
     _tankService         = tankService;
     _discountService     = discountService;
 }
            public void WhenTankExists_ShouldUpdateSuccessfully(int id, string name, int volume)
            {
                using (var factory = new SqlLiteDbContextFactory())
                {
                    using (var context = factory.CreateContext())
                    {
                        SetupTestData(context);

                        var service = new TankService(context);

                        var tank = InstantiateTank(id, name, volume);
                        service.Update(tank);

                        var updatedTank = service.FindById(id);

                        AssertTank(updatedTank, id, name, volume);
                    }
                }
            }
 public TankController()
 {
     _tankService = new TankService();
 }
Example #15
0
        public void Init()
        {
            var result = File.ReadAllText(@"C:\Users\LocalAdmin\Source\Repos\Serverless-Code-Camp\TankWars\TankWars.Test\result.json");

            _service = new TankService(result);
        }
Example #16
0
 protected override void Awake()
 {
     base.Awake();
     tankService = GetComponent <TankService>();
 }
Example #17
0
 public HomeController(TankService tankService, MedalService medalService, UserStatisticsService userStatisticsService)
 {
     _tankService           = tankService;
     _medalService          = medalService;
     _userStatisticsService = userStatisticsService;
 }
 public TankController(AppDbContext context, TankService tankService, ProductService productService)
 {
     _context        = context;
     _tankService    = tankService;
     _productService = productService;
 }