Exemple #1
0
 internal Fuel(FuelCard fuelCard, DateTime date, EngineType engineType)
 {
     FuelCard   = fuelCard;
     Date       = date;
     EngineType = engineType;
     Value      = 0;
 }
Exemple #2
0
        public void PostRecordReturnsOkWhenModelIsValid()
        {
            var validModel = new RecordModel
            {
                FuelCardId       = 1,
                CorporationId    = 1,
                CostAllocationId = 1
            };

            var fuelCard       = new FuelCard();
            var corporation    = new Corporation();
            var costAllocation = new CostAllocation();

            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);
            _corporationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(corporation);
            _costAllocationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(costAllocation);
            _mapperMock.Setup(m => m.Map <RecordReturnModel>(It.IsAny <Record>()))
            .Returns(new RecordReturnModel());
            _mapperMock.Setup(m => m.Map <Record>(It.IsAny <RecordModel>()))
            .Returns(new Record());
            var result = _sut.PostEntity(validModel) as OkObjectResult;

            Assert.That(result, Is.Not.Null);
            Assert.That((RecordReturnModel)result.Value, Is.Not.Null);

            _recordRepositoryMock.Verify(m => m.Add(It.IsAny <Record>()), Times.Once);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _corporationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _costAllocationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _recordRepositoryMock.Verify(m => m.Find(It.IsAny <Expression <Func <Record, bool> > >()), Times.Once);
        }
Exemple #3
0
 public FuelCardDriver(FuelCard fuelCard)
 {
     FuelCard = fuelCard;
     DateBegin = DateTime.Today;
     Driver = DriverList.getInstance().getItem(1);
     IsNotUse = false;
 }
Exemple #4
0
        public void PostRecordReturnsNotFoundWhenCostAllocationIsNotFound()
        {
            var validModel = new RecordModel
            {
                FuelCardId       = 1,
                CorporationId    = 1,
                CostAllocationId = 1
            };

            var            fuelCard       = new FuelCard();
            var            corporation    = new Corporation();
            CostAllocation costAllocation = null;

            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);
            _corporationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(corporation);
            _costAllocationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(costAllocation);

            var result = _sut.PostEntity(validModel) as NotFoundObjectResult;

            Assert.That(result, Is.Not.Null);

            _recordRepositoryMock.Verify(m => m.Add(It.IsAny <Record>()), Times.Never);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _corporationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _costAllocationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _recordRepositoryMock.Verify(m => m.Find(It.IsAny <Expression <Func <Record, bool> > >()), Times.Never);
        }
Exemple #5
0
        public void UpdateRecordReturnsBadRequestWhenModelIsInvalid()
        {
            var invalidModel = new RecordModel
            {
                FuelCardId       = 1,
                CorporationId    = 1,
                CostAllocationId = 1
            };

            var fuelCard       = new FuelCard();
            var corporation    = new Corporation();
            var costAllocation = new CostAllocation();

            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);
            _corporationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(corporation);
            _costAllocationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(costAllocation);

            _sut.ModelState.AddModelError("name", "name is required");

            var result = _sut.UpdateEntity(invalidModel, 1) as BadRequestResult;

            Assert.That(result, Is.Not.Null);

            _recordRepositoryMock.Verify(m => m.Update(It.IsAny <int>(), It.IsAny <Record>()), Times.Never);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _corporationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _costAllocationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _recordRepositoryMock.Verify(m => m.Find(It.IsAny <Expression <Func <Record, bool> > >()), Times.Once);
        }
Exemple #6
0
        public void UpdateRecordReturnsOkWhenEverythingIsCorrect()
        {
            var validModel = new RecordModel
            {
                Id               = 1,
                FuelCardId       = 1,
                CorporationId    = 1,
                CostAllocationId = 1
            };

            var fuelCard       = new FuelCard();
            var corporation    = new Corporation();
            var costAllocation = new CostAllocation();

            _recordRepositoryMock.Setup(m => m.Update(It.IsAny <int>(), It.IsAny <Record>()))
            .Returns(true);
            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);
            _corporationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(corporation);
            _costAllocationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(costAllocation);

            var result = _sut.UpdateEntity(validModel, validModel.Id) as OkResult;

            Assert.That(result, Is.Not.Null);

            _recordRepositoryMock.Verify(m => m.Update(It.IsAny <int>(), It.IsAny <Record>()), Times.Once);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _corporationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _costAllocationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _recordRepositoryMock.Verify(m => m.Find(It.IsAny <Expression <Func <Record, bool> > >()), Times.Once);
        }
Exemple #7
0
        internal void Add(FuelCard fuelCard)
        {
            if (_list.Exists(item => item.ID == fuelCard.ID))
                return;

            _list.Add(fuelCard);
        }
Exemple #8
0
 internal Fuel(FuelCard fuelCard, DateTime date, EngineType engineType)
 {
     FuelCard = fuelCard;
     Date = date;
     EngineType = engineType;
     Value = 0;
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (_workWithForm.IsEditMode())
            {
                int idDriver;
                int.TryParse(cbDriver.SelectedValue.ToString(), out idDriver);
                _fuelCardDriver.Driver    = DriverList.getInstance().getItem(idDriver);
                _fuelCardDriver.DateBegin = dtpDateBegin.Value;

                if (chbNotUse.Checked)
                {
                    if ((!_fuelCardDriver.IsNotUse) && (chbNotUse.Checked))
                    {
                        FuelCard       fuelCard       = _fuelCardDriver.FuelCard;
                        FuelCardDriver fuelCardDriver = fuelCard.CreateFuelCardDriver();
                        fuelCardDriver.Save();
                    }

                    _fuelCardDriver.DateEnd = dtpDateEnd.Value.Date;
                }
                else
                {
                    _fuelCardDriver.IsNotUse = false;
                }

                _fuelCardDriver.Save();

                DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else
            {
                _workWithForm.SetEditMode(true);
            }
        }
Exemple #10
0
        private void SetFormatFuelCard()
        {
            HideColumn("Начало использования");
            HideColumn("Окончание использования");

            FuelCardList fuelCardList = FuelCardList.getInstance();

            foreach (DataGridViewRow row in _dgv.Rows)
            {
                int id;
                int.TryParse(row.Cells[1].Value.ToString(), out id);

                FuelCard fuelCard = fuelCardList.getItem(id);

                if (fuelCard.IsVoid)
                {
                    row.DefaultCellStyle.BackColor = BBColors.bbGray4;
                }
                else if (row.Cells["Водитель"].Value.ToString() == "(Резерв)")
                {
                    row.DefaultCellStyle.BackColor = BBColors.bbGreen3;
                }
                else
                {
                    row.DefaultCellStyle.BackColor = Color.White;
                }
            }
        }
Exemple #11
0
        public void UpdateRecordReturnsBadRequestWhenIdFromModelDoesNotMatchIdFromQueryParameter()
        {
            var validModel = new RecordModel
            {
                FuelCardId       = 1,
                CorporationId    = 1,
                CostAllocationId = 1
            };

            var fuelCard       = new FuelCard();
            var corporation    = new Corporation();
            var costAllocation = new CostAllocation();

            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);
            _corporationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(corporation);
            _costAllocationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(costAllocation);

            var result = _sut.UpdateEntity(validModel, validModel.Id + 1) as BadRequestObjectResult;

            Assert.That(result, Is.Not.Null);

            _recordRepositoryMock.Verify(m => m.Update(It.IsAny <int>(), It.IsAny <Record>()), Times.Never);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _corporationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _costAllocationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _recordRepositoryMock.Verify(m => m.Find(It.IsAny <Expression <Func <Record, bool> > >()), Times.Once);
        }
        public FuelCard_AddEdit(FuelCard fuelCard)
        {
            InitializeComponent();

            fuelCardDriverList = FuelCardDriverList.getInstance();

            _fuelCard = fuelCard;
        }
        public void DriverFuelCardPropertyGetsAndSetsFuelCard()
        {
            var fuelCard = new FuelCard();

            _sut.FuelCard = fuelCard;

            Assert.That(_sut.FuelCard, Is.EqualTo(fuelCard));
        }
Exemple #14
0
 public void OnFuelCardPlayedFromDatabase(Pawn _owner, FuelCard _fuelCard, int _numberOfFuelCard)
 {
     m_playedCardFrontView.UpdateCardView(_owner, _fuelCard, _enableButtton: false);
     m_cardPlayedPlayerNameText.text = "Card Played Player Name : " + _owner.m_PawnInfo.m_PlayerInfo.m_PlayerName;
     GameplayCanvasManager.m_Instance.EnableOrDisableAllUpperButton(true);
     GameplayCanvasManager.m_Instance.ShowGameplayCanvasMenu(GameplayCanvasMenu.PlayedCardViewPanel);
     _fuelCard.OnPlayed(_owner, _numberOfFuelCard);
 }
Exemple #15
0
        public FuelCard_AddEdit(FuelCard fuelCard)
        {
            InitializeComponent();

            fuelCardDriverList = FuelCardDriverList.getInstance();

            _fuelCard = fuelCard;
        }
        public void Delete(int idFuelCard)
        {
            FuelCard fuelCard = getItem(idFuelCard);

            _list.Remove(fuelCard);

            fuelCard.Delete();
        }
        internal void Add(FuelCard fuelCard)
        {
            if (_list.Exists(item => item.Id == fuelCard.Id))
            {
                return;
            }

            _list.Add(fuelCard);
        }
        public void GetFuelCardByIdReturnsNotFoundWhenFuelCardDoesNotExist()
        {
            FuelCard fuelCard = null;

            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);

            var result = _sut.GetEntityById(0) as NotFoundObjectResult;

            Assert.That(result, Is.Not.Null);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
        }
        protected override void LoadFromSql()
        {
            DataTable dt = Provider.Select("FuelCard");

            _list.Clear();

            foreach (DataRow row in dt.Rows)
            {
                FuelCard fuelCard = new FuelCard(row);
                Add(fuelCard);
            }
        }
Exemple #20
0
        protected override void loadFromSql()
        {
            DataTable dt = _provider.Select("FuelCard");

            _list.Clear();

            foreach (DataRow row in dt.Rows)
            {
                FuelCard fuelCard = new FuelCard(row);
                Add(fuelCard);
            }
        }
Exemple #21
0
        private static void LoadNeste(ExcelDoc excel)
        {
            int i = 4; //начальный индекс

            string currentCell = "A" + i;

            while (excel.getValue(currentCell) != null)
            {
                if (excel.getValue(currentCell).ToString() == "Grand Total")
                {
                    break;
                }

                currentCell = "B" + i;
                if (excel.getValue(currentCell) != null)
                {
                    i++;
                    currentCell = "A" + i;
                    continue;
                }

                currentCell = "A" + i;
                string   number   = excel.getValue(currentCell).ToString().Split(' ')[1]; //split example Карта: 7105066553656018
                FuelCard fuelCard = fuelCardList.getItem(number);
                if (fuelCard == null)
                {
                    i++;
                    erorrs.Add("Не найдена карта №" + number); //throw new NullReferenceException("Не найдена карта №" + number);
                    continue;
                }

                currentCell = "C" + i;
                DateTime datetime;
                DateTime.TryParse(excel.getValue(currentCell).ToString(),
                                  out datetime); //присутствует время, не забываем убирать

                currentCell = "D" + i;
                string     engineTypeName = excel.getValue(currentCell).ToString();
                EngineType engineType     = GetEngineType(engineTypeName);

                currentCell = "E" + i;
                double value;
                double.TryParse(excel.getValue(currentCell).ToString(), out value);

                Fuel fuel = new Fuel(fuelCard, datetime.Date, engineType);
                fuel.AddValue(value);
                fuel.Save();

                i++;
                currentCell = "A" + i;
            }
        }
        public void DeleteFuelCardReturnsOkWhenEverythingIsCorrect()
        {
            var fuelCard = new FuelCard();

            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);

            var result = _sut.DeleteEntity(1) as OkResult;

            Assert.That(result, Is.Not.Null);

            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _fuelCardRepositoryMock.Verify(m => m.Remove(It.IsAny <FuelCard>()), Times.Once);
        }
        public void DeleteFuelCardReturnsNotFoundWhenFuelCardIsNotFound()
        {
            FuelCard fuelCard = null;

            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);

            var result = _sut.DeleteEntity(1) as NotFoundObjectResult;

            Assert.That(result, Is.Not.Null);

            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _fuelCardRepositoryMock.Verify(m => m.Remove(It.IsAny <FuelCard>()), Times.Never);
        }
Exemple #24
0
        public Fuel getItem(FuelCard fuelCard, DateTime date, EngineType engineType)
        {
            var fuels = list.Where(item => item.FuelCard.ID == fuelCard.ID && item.Date == date && item.EngineType.ID == engineType.ID);

            if (fuels.Count() > 0)
            {
                return(fuels.First());
            }

            Fuel fuel = new Fuel(fuelCard, date, engineType);

            Add(fuel);

            return(fuel);
        }
        public void GetFuelCardByIdReturnsOkAndFuelCardWhenEverythingIsCorrect()
        {
            var fuelCard = new FuelCard();

            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);
            _mapperMock.Setup(m => m.Map <FuelCardReturnModel>(It.IsAny <FuelCard>()))
            .Returns(new FuelCardReturnModel());
            var result = _sut.GetEntityById(0) as OkObjectResult;

            Assert.That(result, Is.Not.Null);

            var value = result.Value as FuelCardReturnModel;

            Assert.That(value, Is.Not.Null);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
        }
Exemple #26
0
        private void DoubleClickFuelCard(Point point)
        {
            int id = _dgvMain.GetCarID();

            if (id == 0)
            {
                return;
            }

            FuelCardList fuelCardList = FuelCardList.getInstance();
            FuelCard     fuelCard     = fuelCardList.getItem(id);

            FuelCard_AddEdit fuelCardAddEdit = new FuelCard_AddEdit(fuelCard);

            if (fuelCardAddEdit.ShowDialog() == DialogResult.OK)
            {
                loadCars();
            }
        }
Exemple #27
0
        public void UpdateRecordReturnsBadRequestWhenFuelCardAlreadyExistsAndIsntFromUpdatingRecord()
        {
            var validModel = new RecordModel
            {
                Id               = 1,
                FuelCardId       = 1,
                CorporationId    = 1,
                CostAllocationId = 1
            };

            var fuelCard       = new FuelCard();
            var corporation    = new Corporation();
            var costAllocation = new CostAllocation();
            var records        = new List <Record>
            {
                new Record
                {
                    Id = validModel.Id + 1
                }
            };

            _recordRepositoryMock.Setup(m => m.Update(It.IsAny <int>(), It.IsAny <Record>()))
            .Returns(true);
            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);
            _corporationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(corporation);
            _costAllocationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(costAllocation);
            _recordRepositoryMock.Setup(m => m.Find(It.IsAny <Expression <Func <Record, bool> > >()))
            .Returns(records);

            var result = _sut.UpdateEntity(validModel, validModel.Id) as BadRequestObjectResult;

            Assert.That(result, Is.Not.Null);

            _recordRepositoryMock.Verify(m => m.Update(It.IsAny <int>(), It.IsAny <Record>()), Times.Never);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _corporationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _costAllocationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _recordRepositoryMock.Verify(m => m.Find(It.IsAny <Expression <Func <Record, bool> > >()), Times.Once);
        }
Exemple #28
0
        private static void LoadPetrol(ExcelDoc excel)
        {
            int i = 4; //начальный индекс

            string currentCell = "B" + i;

            while (excel.getValue(currentCell) != null)
            {
                currentCell = "D" + i;
                string   number   = excel.getValue(currentCell).ToString();
                FuelCard fuelCard = fuelCardList.getItem(number);
                if (fuelCard == null)
                {
                    i++;
                    currentCell = "B" + i;
                    erorrs.Add("Не найдена карта №" + number); //throw new NullReferenceException("Не найдена карта №" + number);
                    continue;
                }

                currentCell = "B" + i;
                string   dateString = excel.getValue1(currentCell).ToString();
                DateTime datetime;
                DateTime.TryParse(dateString, out datetime);//присутствует время, не забываем убирать

                currentCell = "G" + i;
                string     engineTypeName = excel.getValue(currentCell).ToString();
                EngineType engineType     = GetEngineType(engineTypeName);

                currentCell = "H" + i;
                double value;
                double.TryParse(excel.getValue(currentCell).ToString(), out value);

                Fuel fuel = new Fuel(fuelCard, datetime.Date, engineType);
                fuel.AddValue(value);
                fuel.Save();

                i++;
                currentCell = "B" + i;
            }
        }
Exemple #29
0
    public void OnFuelCardPlayed(Pawn _owner, FuelCard _fuelCard, int _numberFuelCards)
    {
        if (!IsMyTurn(_owner.m_PawnInfo.m_PlayerInfo))
        {
            Toast.m_Instance.ShowMessage("You can't play the card. This is not your turn...");
            return;
        }

        if (_fuelCard.CanPlayCard(_owner, _numberFuelCards))
        {
            Toast.m_Instance.ShowMessage("Fuel card is played...");

            if (GameManager.m_Instance.m_GameType == GameType.Offline)
            {
                m_playedCardFrontView.UpdateCardView(_owner, _fuelCard, _enableButtton: false);
                GameplayCanvasManager.m_Instance.ShowGameplayCanvasMenu(GameplayCanvasMenu.PlayedCardViewPanel);
                m_cardPlayedPlayerNameText.text = "Card Played Player Name : " + _owner.m_PawnInfo.m_PlayerInfo.m_PlayerName;
                _fuelCard.OnPlayed(_owner, _numberFuelCards);
            }
            else if (GameManager.m_Instance.m_GameType == GameType.Online)
            {
                if (GameManager.m_Instance.m_OwnerInfo != null)
                {
                    m_pickCardView.ObscurePickCardView(true);
                    GameplayCanvasManager.m_Instance.EnableOrDisableAllUpperButton(false);
                    FirebaseRealtimeDatabase.m_Instance.UpdatePlayedCard(GameManager.m_Instance.m_OwnerInfo.m_PlayerUID, _fuelCard, _numberFuelCards, null);
                }
                else
                {
                    Toast.m_Instance.ShowMessage("You did not set the gameManager owner");
                }
            }
        }
        else
        {
            Toast.m_Instance.ShowMessage("You can't play card : " + _fuelCard.name);
        }
    }
Exemple #30
0
        public void UpdateRecordReturnsNotFoundWhenFuelCardIsNotFound()
        {
            var validModel = new RecordModel
            {
                Id         = 1,
                FuelCardId = 1
            };

            FuelCard fuelCard = null;

            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);

            var result = _sut.UpdateEntity(validModel, validModel.Id) as NotFoundObjectResult;

            Assert.That(result, Is.Not.Null);

            _recordRepositoryMock.Verify(m => m.Update(It.IsAny <int>(), It.IsAny <Record>()), Times.Never);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _corporationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Never);
            _costAllocationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Never);
            _recordRepositoryMock.Verify(m => m.Find(It.IsAny <Expression <Func <Record, bool> > >()), Times.Never);
        }
        public void FindIncludesAllRelationsOfVehicle()
        {
            var brand = new Brand();
            var model = new Model
            {
                Brand = brand
            };
            var fuelType   = new FuelType();
            var engineType = new EngineType
            {
                Brand = brand
            };
            var series = new Series
            {
                Brand = brand
            };
            var doorType      = new DoorType();
            var category      = new Category();
            var country       = new Country();
            var exteriorColor = new ExteriorColor
            {
                Brand = brand
            };
            var interiorColor = new InteriorColor
            {
                Brand = brand
            };
            var person = new Person();
            var driver = new Driver
            {
                Person = person
            };
            var fuelCard = new FuelCard
            {
                Driver = driver
            };
            var vehicle = new Vehicle
            {
                Brand         = brand,
                Model         = model,
                FuelType      = fuelType,
                EngineType    = engineType,
                Series        = series,
                DoorType      = doorType,
                Category      = category,
                Country       = country,
                ExteriorColor = exteriorColor,
                InteriorColor = interiorColor,
                FuelCard      = fuelCard
            };

            _sut.Add(vehicle);

            var vehicleFromDatabase = _sut.Find(v => v.Id == vehicle.Id).FirstOrDefault();

            Assert.That(vehicleFromDatabase.Brand, Is.EqualTo(brand));
            Assert.That(vehicleFromDatabase.Model, Is.EqualTo(model));
            Assert.That(vehicleFromDatabase.FuelType, Is.EqualTo(fuelType));
            Assert.That(vehicleFromDatabase.EngineType, Is.EqualTo(engineType));
            Assert.That(vehicleFromDatabase.Series, Is.EqualTo(series));
            Assert.That(vehicleFromDatabase.DoorType, Is.EqualTo(doorType));
            Assert.That(vehicleFromDatabase.Category, Is.EqualTo(category));
            Assert.That(vehicleFromDatabase.Country, Is.EqualTo(country));
            Assert.That(vehicleFromDatabase.ExteriorColor, Is.EqualTo(exteriorColor));
            Assert.That(vehicleFromDatabase.InteriorColor, Is.EqualTo(interiorColor));
            Assert.That(vehicleFromDatabase.FuelCard, Is.EqualTo(fuelCard));
            Assert.That(vehicleFromDatabase.FuelCard.Driver, Is.EqualTo(driver));
            Assert.That(vehicleFromDatabase.FuelCard.Driver.Person, Is.EqualTo(person));
        }
    // Call by Firebase realtime database
    // called when player played the card
    public void OnCardPlayed(object _sender, ValueChangedEventArgs _valueChangedEventArgs)
    {
        if (_valueChangedEventArgs.DatabaseError != null)
        {
            Toast.m_Instance.ShowMessage("On Card played is error " + _valueChangedEventArgs.DatabaseError.Details);
            return;
        }

        if (_valueChangedEventArgs.Snapshot.Exists)
        {
            DataSnapshot _dataSnapshot = _valueChangedEventArgs.Snapshot;

            if (m_GameInfo.m_CreatorUID == _dataSnapshot.Child(FirebaseRealtimeDatabase.r_gameCreatorUID).Value.ToString())
            {
                if (GameplayManager.m_Instance != null)
                {
                    string _playerUID = _dataSnapshot.Child(FirebaseRealtimeDatabase.r_playingPlayerUID).Value.ToString();

                    if (GameplayManager.m_Instance.m_PawnsDict.ContainsKey(_playerUID))
                    {
                        Pawn _owner = GameplayManager.m_Instance.m_PawnsDict[_playerUID];

                        string _playedCardName = _dataSnapshot.Child(FirebaseRealtimeDatabase.r_playedCard).Child(FirebaseRealtimeDatabase.r_cardName).Value.ToString();
                        string _playedCardType = _dataSnapshot.Child(FirebaseRealtimeDatabase.r_playedCard).Child(FirebaseRealtimeDatabase.r_cardType).Value.ToString();

                        if (_playedCardType != typeof(FuelCard).ToString())
                        {
                            string _pickedCardName = _dataSnapshot.Child(FirebaseRealtimeDatabase.r_pickedCard).Child(FirebaseRealtimeDatabase.r_cardName).Value.ToString();
                            string _pickedCardType = _dataSnapshot.Child(FirebaseRealtimeDatabase.r_pickedCard).Child(FirebaseRealtimeDatabase.r_cardType).Value.ToString();

                            if (_playedCardType == typeof(TrapCard).ToString())
                            {
                                Card _playedCard = CardManager.m_Instance.GetTrapCardByName(_playedCardName);
                                Card _pickedCard = CardManager.m_Instance.GetTrapCardByName(_pickedCardName);

                                if (_playedCard != null && _pickedCard != null)
                                {
                                    GameplayManager.m_Instance.OnPlayedCardFromDatabse(_owner, _playedCard, _pickedCard);
                                }
                            }
                            else
                            {
                                Card _playedCard = CardManager.m_Instance.GetPowerOrHourCardByName(_playedCardName);
                                Card _pickedCard = CardManager.m_Instance.GetPowerOrHourCardByName(_pickedCardName);

                                if (_playedCard != null && _pickedCard != null)
                                {
                                    if (_playedCard.GetType() == typeof(PowerCard))
                                    {
                                        if (((PowerCard)_playedCard).m_powerType == PowerTypes.GMTMaster || ((PowerCard)_playedCard).m_powerType == PowerTypes.Master)
                                        {
                                            string _value  = _dataSnapshot.Child(FirebaseRealtimeDatabase.r_playedCard).Child(FirebaseRealtimeDatabase.r_cardValue).Value.ToString();
                                            int    _result = 0;
                                            if (int.TryParse(_value, out _result))
                                            {
                                                GameplayManager.m_Instance.OnPlayedCardFromDatabse(_owner, _playedCard, _pickedCard, _result);
                                            }
                                        }
                                        else
                                        {
                                            GameplayManager.m_Instance.OnPlayedCardFromDatabse(_owner, _playedCard, _pickedCard);
                                        }
                                    }
                                    else
                                    {
                                        GameplayManager.m_Instance.OnPlayedCardFromDatabse(_owner, _playedCard, _pickedCard);
                                    }
                                }
                            }
                        }
                        else
                        {
                            string _value = _dataSnapshot.Child(FirebaseRealtimeDatabase.r_playedCard).Child(FirebaseRealtimeDatabase.r_cardValue).Value.ToString();

                            int _result = 0;
                            if (int.TryParse(_value, out _result))
                            {
                                FuelCard _fuelCard = CardManager.m_Instance.m_FuelCard;
                                GameplayManager.m_Instance.OnFuelCardPlayedFromDatabase(_owner, _fuelCard, _result);
                            }
                        }
                    }
                }
            }
        }
    }
        public void GetAllIncludesAllRelationsOfRecord()
        {
            var brand = new Brand();
            var model = new Model
            {
                Brand = brand
            };
            var fuelType   = new FuelType();
            var engineType = new EngineType
            {
                Brand = brand
            };
            var series = new Series
            {
                Brand = brand
            };
            var doorType      = new DoorType();
            var category      = new Category();
            var country       = new Country();
            var exteriorColor = new ExteriorColor
            {
                Brand = brand
            };
            var interiorColor = new InteriorColor
            {
                Brand = brand
            };
            var person = new Person();
            var driver = new Driver
            {
                Person = person
            };
            var vehicle = new Vehicle
            {
                Brand         = brand,
                Model         = model,
                FuelType      = fuelType,
                EngineType    = engineType,
                Series        = series,
                DoorType      = doorType,
                Category      = category,
                Country       = country,
                ExteriorColor = exteriorColor,
                InteriorColor = interiorColor
            };
            var fuelCard = new FuelCard
            {
                Driver  = driver,
                Vehicle = vehicle
            };

            var costAllocation = new CostAllocation();
            var company        = new Company();
            var corporation    = new Corporation
            {
                Company = company
            };

            var record = new Record
            {
                FuelCard       = fuelCard,
                CostAllocation = costAllocation,
                Corporation    = corporation
            };

            _sut.Add(record);

            var records = _sut.GetAll();

            Assert.That(records, Is.Not.Null);

            var recordFromDatabase = records.FirstOrDefault(r => r.Id == record.Id);

            Assert.That(recordFromDatabase.CostAllocation, Is.EqualTo(costAllocation));
            Assert.That(recordFromDatabase.Corporation, Is.EqualTo(corporation));
            Assert.That(recordFromDatabase.Corporation.Company, Is.EqualTo(company));
            Assert.That(recordFromDatabase.FuelCard.Vehicle.Brand, Is.EqualTo(brand));
            Assert.That(recordFromDatabase.FuelCard.Vehicle.Model, Is.EqualTo(model));
            Assert.That(recordFromDatabase.FuelCard.Vehicle.FuelType, Is.EqualTo(fuelType));
            Assert.That(recordFromDatabase.FuelCard.Vehicle.EngineType, Is.EqualTo(engineType));
            Assert.That(recordFromDatabase.FuelCard.Vehicle.Series, Is.EqualTo(series));
            Assert.That(recordFromDatabase.FuelCard.Vehicle.DoorType, Is.EqualTo(doorType));
            Assert.That(recordFromDatabase.FuelCard.Vehicle.Category, Is.EqualTo(category));
            Assert.That(recordFromDatabase.FuelCard.Vehicle.Country, Is.EqualTo(country));
            Assert.That(recordFromDatabase.FuelCard.Vehicle.ExteriorColor, Is.EqualTo(exteriorColor));
            Assert.That(recordFromDatabase.FuelCard.Vehicle.InteriorColor, Is.EqualTo(interiorColor));
            Assert.That(recordFromDatabase.FuelCard.Vehicle.FuelCard, Is.EqualTo(fuelCard));
            Assert.That(recordFromDatabase.FuelCard.Driver, Is.EqualTo(driver));
            Assert.That(recordFromDatabase.FuelCard.Driver.Person, Is.EqualTo(person));
        }
 public FuelCardDriver getItem(FuelCard fuelCard)
 {
     return list.Where(item => item.FuelCard == fuelCard).OrderByDescending(item => item.DateBegin).FirstOrDefault();
 }
 public DataTable ToDataTable(FuelCard fuelCard)
 {
     return(createTable(
                list.Where(item => item.FuelCard.ID == fuelCard.ID).OrderByDescending(item => item.DateBegin)
                ));
 }
 public FuelCardDriver getItem(FuelCard fuelCard)
 {
     return(list.Where(item => item.FuelCard == fuelCard).OrderByDescending(item => item.DateBegin).FirstOrDefault());
 }
 public DataTable ToDataTable(FuelCard fuelCard)
 {
     return createTable(
         list.Where(item => item.FuelCard.ID == fuelCard.ID).OrderByDescending(item => item.DateBegin)
     );
 }