Пример #1
0
 private static List <VehicleCountByType> GetNumberOfVehiclesByType(IAmRally rally)
 {
     return(rally.Vehicles.Values
            .GroupBy(vehicle => vehicle.Type)
            .Select(group =>
                    new VehicleCountByType(group.Key.ToDto(), group.Count()))
            .ToList());
 }
Пример #2
0
        public static IAmRallyRepository SetUpRepoWithRally(string rallyId, IAmRally rally)
        {
            var rallyRepoMock = new Mock <IAmRallyRepository>();

            rallyRepoMock
            .Setup(repo => repo.Find(rallyId))
            .Returns(Result.Ok <IAmRally>(rally));
            return(rallyRepoMock.Object);
        }
Пример #3
0
 public RallyStatusInfo Create(IAmRally rally)
 {
     return(new RallyStatusInfo
     {
         Status = GetStatus(rally),
         NumberOfVehiclesByStatus = GetNumberOfVehiclesByStatus(rally),
         NumberOfVehiclesByType = GetNumberOfVehiclesByType(rally)
     });
 }
Пример #4
0
 private RallyStatus GetStatus(IAmRally rally)
 {
     return(rally.GetStatus().ToDto());
 }
Пример #5
0
 public Result Add(IAmRally rally)
 {
     return(Result.Create(!_rallies.ContainsKey(rally.Id), "Already exists.")
            .OnSuccess(() => _rallies.Add(rally.Id, rally)));
 }