Esempio n. 1
0
 public Services.TripSearchRequest ToService(IDestinationRepository repo)
 {
     return(new TripSearchRequest(
                // TODO Refactor
                repo.FindByName(StartLocation).FirstOrNone().ValueOr((Domain.Destination)null),
                repo.FindByName(EndLocation).FirstOrNone().ValueOr((Domain.Destination)null),
                StartTime
                ));
 }
Esempio n. 2
0
 public Option <Domain.TripOffer, string> ToDomain(IDestinationRepository destRepo)
 {
     return
         (destRepo.FindByName(StartLocation)
          .FirstOrNone()
          .WithException($"Start location '{StartLocation}' could not matched!")
          .FlatMap(start =>
                   destRepo.FindByName(EndLocation)
                   .FirstOrNone()
                   .WithException($"End location '{EndLocation}' could not matched!")
                   .Map(end => new Domain.TripOffer(StarTime, start,
                                                    EndTime - StarTime, end,
                                                    new Domain.User(null, OfferedBy))
                        )
                   ));
 }
Esempio n. 3
0
        public void TestSearchByName()
        {
            Assert.AreEqual("Linz",
                            repo.FindByName("linz").FirstOrNone().ValueOr(() => null)?.Name);
            Assert.AreEqual("Waidhofen an der Ybbs",
                            repo.FindByName("waid").FirstOrNone().ValueOr(() => null)?.Name);
            Assert.AreEqual("Waidhofen an der Ybbs",
                            repo.FindByName("Waid").FirstOrNone().ValueOr(() => null)?.Name);

            Assert.IsNull(repo.FindByName("ybba").FirstOrNone().ValueOr(() => null));
            Assert.IsNull(repo.FindByName("bla").FirstOrNone().ValueOr(() => null));
            Assert.IsNull(repo.FindByName("lanzen").FirstOrNone().ValueOr(() => null));
            Assert.IsNull(repo.FindByName("Ander").FirstOrNone().ValueOr(() => null));
        }