public void UpdateVoyageId_ValidFuelReport_ValidVoyageId()
        {
            #region Arrange

            var fetchStategy = new ListFetchStrategy<FuelReport>();

            fetchStategy.OrderByDescending(en => en.Id);

            long validFuelReportId = this.testObjects.FuelReportRepository.GetAll(fetchStategy).First().Id;

            long validVoyageId = this.testObjects.VoyageDomainService.GetAll().OrderBy(v => v.Id).LastOrDefault().Id;

            #endregion

            #region Action

            Exception thrownException = null;

            FuelReport result = null;

            try
            {
                result = this.testObjects.FuelReportApplicationService.UpdateVoyageId(validFuelReportId, validVoyageId);
            }
            catch (Exception ex)
            {
                thrownException = ex;
            }

            #endregion

            #region Assert

            Assert.IsNull(thrownException);

            Assert.IsNotNull(result);

            this.testObjects.RegenerateUnitOfWorkScope();

            var assertionRepository = new FuelReportRepository(this.testObjects.UnitOfWorkScope, testObjects.FuelReportConfigurator);

            FuelReport updatedFuelReport = assertionRepository.Find(fr => fr.Id == validFuelReportId).FirstOrDefault();

            Assert.IsNotNull(updatedFuelReport);

            Assert.IsNotNull(updatedFuelReport.Voyage);

            Assert.AreEqual(validVoyageId, updatedFuelReport.Voyage.Id);

            #endregion
        }
        public void UpdateVoyageId_ValidFuelReport_InvalidVoyageId()
        {
            #region Arrange

            var fetchStategy = new ListFetchStrategy<FuelReport>();

            fetchStategy.OrderByDescending(en => en.Id);

            long validFuelReportId = this.testObjects.FuelReportRepository.GetAll(fetchStategy).First().Id;

            long invalidVoyageId = this.testObjects.VoyageDomainService.GetAll().OrderBy(v => v.Id).LastOrDefault().Id + 1;

            #endregion

            #region Action

            Exception thrownException = null;

            try
            {
                FuelReport result = this.testObjects.FuelReportApplicationService.UpdateVoyageId(validFuelReportId, invalidVoyageId);
            }
            catch (Exception ex)
            {
                thrownException = ex;
            }

            #endregion

            #region Assert

            Assert.IsNotNull(thrownException);

            Assert.IsInstanceOfType(thrownException, typeof(BusinessRuleException));

            Assert.AreEqual(((BusinessRuleException)thrownException).BusinessRuleCode, "BR_FR2");

            #endregion
        }
        public void UpdateFuelReportDetail_InvlaidFuelReport()
        {
            #region Arrange

            var fetchStategy = new ListFetchStrategy<FuelReport>();

            fetchStategy.OrderByDescending(en => en.Id);

            long invalidFuelReportId = this.testObjects.FuelReportRepository.GetAll(fetchStategy).First().Id + 1;

            #endregion

            #region Action

            Exception thrownException = null;

            FuelReportDetail result = null;

            try
            {
                //result = testObjects.Target.UpdateFuelReportDetail(invalidFuelReportId, 1, 1, 1, 1, ReceiveTypes.InternalTransfer, 1, TransferTypes.InternalTransfer, 1, CorrectionTypes.Plus, 1, 1, null, null, null);
            }
            catch (Exception ex)
            {
                thrownException = ex;
            }

            #endregion

            #region Assert

            Assert.IsNotNull(thrownException);

            Assert.IsInstanceOfType(thrownException, typeof(ObjectNotFound));

            #endregion
        }
        public void UpdateVoyageId_InvalidFuelReport()
        {
            #region Arrange

            var fetchStategy = new ListFetchStrategy<FuelReport>();

            fetchStategy.OrderByDescending(en => en.Id);

            long invlaidFuelReportId = this.testObjects.FuelReportRepository.GetAll(fetchStategy).First().Id + 1;

            #endregion

            #region Action

            Exception thrownException = null;

            try
            {
                FuelReport result = this.testObjects.FuelReportApplicationService.UpdateVoyageId(invlaidFuelReportId, 5);
            }
            catch (Exception ex)
            {
                thrownException = ex;
            }

            #endregion

            #region Assert

            Assert.IsNotNull(thrownException);

            Assert.IsInstanceOfType(thrownException, typeof(ObjectNotFound));

            #endregion
        }
        public void UpdateFuelReportDetail_InvalidFuelReportDetailId()
        {
            #region Arrange

            var fetchStategy = new ListFetchStrategy<FuelReport>();
            fetchStategy.Include(fr => fr.FuelReportDetails);

            fetchStategy.OrderByDescending(en => en.Id);

            long validFuelReportId = this.testObjects.FuelReportRepository.GetAll(fetchStategy).First().Id;

            FuelReport validFuelReport = this.testObjects.FuelReportRepository.Find(c => c.Id == validFuelReportId, fetchStategy).FirstOrDefault();

            FuelReportDetail lastFuelReportDetail = validFuelReport.FuelReportDetails.OrderByDescending(frd => frd.Id).FirstOrDefault();

            long invalidFuelReportDetailId = 0L;

            if (lastFuelReportDetail != null)
            {
                invalidFuelReportDetailId = lastFuelReportDetail.Id + 1;
            }

            #endregion

            #region Action

            Exception thrownException = null;

            FuelReportDetail result = null;

            try
            {
                result = this.testObjects.FuelReportApplicationService.UpdateFuelReportDetail(validFuelReportId, invalidFuelReportDetailId, 1, 1, 1, ReceiveTypes.InternalTransfer, 1, TransferTypes.InternalTransfer, 1, CorrectionTypes.Plus, 1, 1, null, null, null);
            }
            catch (Exception ex)
            {
                thrownException = ex;
            }

            #endregion

            #region Assert

            Assert.IsNotNull(thrownException);

            Assert.IsInstanceOfType(thrownException, typeof(ObjectNotFound));

            Assert.AreEqual("FuelReportDetail", ((ObjectNotFound)thrownException).EntityName);

            #endregion
        }