コード例 #1
0
        public void GiveTotalPricesTest_PassengerRouteTotalPrice_1()
        {
            //Arrange
            var journeyService = new JourneyService();
            var journey        = new Journey
            {
                Length          = 100,
                PassengerRoutes = new List <PassengerRoute>
                {
                    new PassengerRoute
                    {
                        Length = 100,
                    }
                }
            };
            var priceForLiter        = 2;
            var fuelConsumption100km = 10;

            //Act
            journeyService.GiveTotalPrices(journey, priceForLiter, fuelConsumption100km);
            var expected = 10;
            var actual   = journey.PassengerRoutes[0].TotalPrice;

            //Assert
            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
 public JourneyListViewModel()
 {
     try {
         journeyService = new JourneyService();
     }
     catch (Exception ex)
     {
         throw (ex);
     }
 }
コード例 #3
0
        public JourneyServiceTests()
        {
            mockedJourneyRepository = new Mock <IRepository <Journey> >();

            mockedJourneyRepository.Setup(j => j.Save()).Returns(true);

            mockedCarRepository = new Mock <IRepository <Car> >();

            journeyService = new JourneyService(mockedJourneyRepository.Object, mockedCarRepository.Object);
        }
コード例 #4
0
    public void JourneyService_Returns_Correct_Link()
    {
        var service = new JourneyService();

        var result = service.GetDirectionsLink(
            "B91 1SB",
            new ProviderLocationBuilder().Build());

        result.Should().Be("https://www.google.com/maps/dir/?api=1&origin=B91+1SB&destination=CV1+2WT&travelmode=transit");
    }
コード例 #5
0
 public JourneyController(
     JourneyService journeyService,
     IDatabaseManager databaseManager,
     Authorizer authorizer,
     IHttpContextAccessor httpContextAccessor)
 {
     _journeyService      = journeyService;
     _databaseManager     = databaseManager;
     _authorizer          = authorizer;
     _httpContextAccessor = httpContextAccessor;
 }
コード例 #6
0
        public JourneyViewModel()
        {
            Journey         = new JourneyDTO();
            _journeyService = new JourneyService();
            _driverList     = new List <UserDTO>();
            _vehicleList    = new List <VehicleDTO>();
            _lookService    = new LookupsService();

            _driverList  = _lookService.GetDrivers();
            _vehicleList = _lookService.GetVehicles();

            GetPlacesCommand = new Command <string>(async(param) => await GetPlacesByName(param));
            ShowListView     = false;
            ShowOthers       = !ShowListView;
        }
コード例 #7
0
        public void GiveTotalPricesTest_PassengerRouteTotalPrice_5()
        {
            //Arrange
            var journeyService = new JourneyService();
            var journey        = new Journey
            {
                Length          = 100,
                PassengerRoutes = new List <PassengerRoute>
                {
                    new PassengerRoute
                    {
                        Length = 75,
                    },
                    new PassengerRoute
                    {
                        Length = 50,
                    },
                    new PassengerRoute
                    {
                        Length = 25,
                    },
                    new PassengerRoute
                    {
                        Length = 10,
                    }
                }
            };
            var priceForLiter        = 2;
            var fuelConsumption100km = 10;

            //Act
            journeyService.GiveTotalPrices(journey, priceForLiter, fuelConsumption100km);
            var expected1 = 5.32m;
            var expected2 = 2.82m;
            var expected3 = 1.15m;
            var expected4 = 0.4m;
            var actual1   = Decimal.Round(journey.PassengerRoutes[0].TotalPrice, 2);
            var actual2   = Decimal.Round(journey.PassengerRoutes[1].TotalPrice, 2);
            var actual3   = Decimal.Round(journey.PassengerRoutes[2].TotalPrice, 2);
            var actual4   = Decimal.Round(journey.PassengerRoutes[3].TotalPrice, 2);

            //Assert
            Assert.AreEqual(expected1, actual1);
            Assert.AreEqual(expected2, actual2);
            Assert.AreEqual(expected3, actual3);
            Assert.AreEqual(expected4, actual4);
        }
コード例 #8
0
ファイル: Journeys.xaml.cs プロジェクト: BalSquad/Green_Walk
        public Journeys()
        {
            InitializeComponent();

            //UserId
            AllJourneys = new ObservableCollection <Journey>(JourneyService.GetJourneysByUser(1).AsEnumerable());

            foreach (Journey j in AllJourneys)
            {
                j.User = new User()
                {
                    FirstName = "Lucas",
                    LastName  = "Tambarin",
                    Pseudo    = "https://picsum.photos/500"
                };
            }

            MyListView.ItemsSource = AllJourneys;
        }
コード例 #9
0
        public async void SaveAsyncTest()
        {
            _journeyService = new JourneyService();
            JourneyDTO journey = new JourneyDTO();

            journey.CompanyId  = 8;
            journey.UserId     = 55;
            journey.DriverId   = 129;
            journey.VehicleId  = 35;
            journey.Fees       = 250;
            journey.FinishDate = DateTime.Now.AddHours(2);
            journey.StartDate  = DateTime.Now.AddHours(1);
            journey.From       = "SDFSDFFFSDF";
            journey.To         = "sdfsfsfssdf";

            int createdId = await _journeyService.SaveAsync(journey);

            Assert.AreEqual(createdId, 1);
        }
コード例 #10
0
        public void GiveTotalPricesTest_JourneyTotalPrice()
        {
            //Arrange
            var journeyService = new JourneyService();
            var journey        = new Journey
            {
                Length = 100
            };
            var priceForLiter        = 2;
            var fuelConsumption100km = 10;

            //Act
            journeyService.GiveTotalPrices(journey, priceForLiter, fuelConsumption100km);

            var expected = 20;
            var actual   = journey.TotalPrice;

            //Assert
            Assert.AreEqual(expected, actual);
        }
コード例 #11
0
        public void Journey_CalculateFare_PeakHoursFareShouldReturn()
        {
            // Arrange
            var journeyDateTime  = Convert.ToDateTime("10-18-2021 10:00");
            var journeyRequest   = TestDataProvider.GetJourneyRequest(journeyDateTime);
            var journeyComponent = new Mock <IJourneyComponent>();

            journeyComponent.Setup(x => x.Commute(It.IsAny <Models.Criteria>(), It.IsAny <Models.Card>()))
            .Returns(new Models.Fare {
                Amount = 25, Description = "Non Peak Fare"
            });

            //Act
            var journeyService  = new JourneyService(journeyComponent.Object);
            var journeyResponse = journeyService.Journey(journeyRequest);

            //Assert
            Assert.NotNull(journeyResponse);
            Assert.True(journeyResponse.Fare.Amount == 25);
        }
コード例 #12
0
        public void GiveTotalPricesTest_PassengerRouteTotalPrice_4()
        {
            //Arrange
            var journeyService = new JourneyService();
            var journey        = new Journey
            {
                Length          = 100,
                PassengerRoutes = new List <PassengerRoute>
                {
                    new PassengerRoute
                    {
                        Length = 100,
                    },
                    new PassengerRoute
                    {
                        Length = 50,
                    },
                    new PassengerRoute
                    {
                        Length = 50,
                    }
                }
            };
            var priceForLiter        = 2;
            var fuelConsumption100km = 10;

            //Act
            journeyService.GiveTotalPrices(journey, priceForLiter, fuelConsumption100km);
            var expected1 = 7.5m;
            var expected2 = 2.5m;
            var expected3 = 2.5m;
            var actual1   = journey.PassengerRoutes[0].TotalPrice;
            var actual2   = journey.PassengerRoutes[1].TotalPrice;
            var actual3   = journey.PassengerRoutes[2].TotalPrice;

            //Assert
            Assert.AreEqual(expected1, actual1);
            Assert.AreEqual(expected2, actual2);
            Assert.AreEqual(expected3, actual3);
        }
コード例 #13
0
        public SchemaQuery(ExerciseService exercises, TrainingScheduleService trainingScheduleService, WorkshopService workshopService, WorkoutService workoutService, JourneyService journeyService)
        {
            Name = "Query";
            Field <ListGraphType <ExerciseType> >(
                "exercises",
                resolve: context => exercises.GetExercisesAsync()
                );

            Field <ListGraphType <TrainingScheduleType> >(
                "trainingSchedules",
                resolve: context => trainingScheduleService.GetTrainingSchedulesAsync()
                );

            Field <ListGraphType <WorkshopType> >(
                "workshops",
                resolve: context => workshopService.GetWorkshopsAsync()
                );

            Field <ListGraphType <WorkoutType> >(
                "workouts",
                resolve: context => workoutService.GetWorkoutsAsync()
                );

            Field <ListGraphType <JourneyType> >(
                "journeys",
                resolve: context => journeyService.GetJourneysAsync()
                );


            FieldAsync <ExerciseType>(
                "exercise",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id"
            }),
                resolve: async context => {
                return(await context.TryAsyncResolve(
                           async c => await exercises.GetExerciseByIdAsync(c.GetArgument <int>("id"))
                           ));
            }
                );


            FieldAsync <JourneyType>(
                "journey",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id"
            }),
                resolve: async context => {
                return(await context.TryAsyncResolve(
                           async c => await journeyService.GetJourneyByIdAsync(c.GetArgument <int>("id"))
                           ));
            }
                );

            FieldAsync <WorkoutType>(
                "workout",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id"
            }),
                resolve: async context => {
                return(await context.TryAsyncResolve(
                           async c => await workoutService.GetWorkoutAsync(c.GetArgument <int>("id"))
                           ));
            }
                );
        }
コード例 #14
0
 public JourneyServiceTests()
 {
     _journeyService = new JourneyService();
 }