public void should_be_bank_to_prince_regent() { const string bank = "Bank"; const string princeRegent = "Prince Regent"; var accountId = Guid.NewGuid(); var tappedAtBankCommand = new DeviceTappedCommand(accountId, bank, "rail"); var tappedAtprinceRegentCommand = new DeviceTappedCommand(accountId, princeRegent, "rail"); var accountSpy = new AccountSpy(); var container = new WindsorContainer(); container.AddFacility <SubstituterFacility>(config => { config.WithContainer(container) .Substitute <IAccount>(sub => sub.Instance(accountSpy)); }); container.Install(new InstallDevices()); var handleDevice = container.Resolve <HandleDevice>(); handleDevice.Handle(tappedAtBankCommand); handleDevice.Handle(tappedAtprinceRegentCommand); Assert.That(accountSpy[accountId].OriginDestination, Is.EqualTo(OriginDestination.OriginToDestination(bank, princeRegent))); Assert.That(accountSpy[accountId].Fare, Is.EqualTo(5)); container.Release(handleDevice); }
public void should_not_rate_for_invalid_journey() { const string bank = "Bank"; var accountId = Guid.NewGuid(); var firstBankTapCommand = new DeviceTappedCommand(accountId, bank, "rail"); var secondBankTapCommand = new DeviceTappedCommand(accountId, bank, "hyperloop"); var accountSpy = new AccountSpy(); var container = new WindsorContainer(); container.AddFacility <SubstituterFacility>(config => { config.WithContainer(container) .Substitute <IAccount>(sub => sub.Instance(accountSpy)); }); container.Install(new InstallDevices()); var handleDevice = container.Resolve <HandleDevice>(); handleDevice.Handle(firstBankTapCommand); handleDevice.Handle(secondBankTapCommand); Assert.That(accountSpy[accountId].OriginDestination, Is.EqualTo(OriginDestination.HereToHere(bank))); Assert.That(accountSpy[accountId].Fare, Is.EqualTo(0)); container.Release(handleDevice); }
public void should_be_bank_to_bank() { const string bank = "Bank"; var accountId = Guid.NewGuid(); var firstBankTapCommand = new DeviceTappedCommand(accountId, bank, "rail"); var secondBankTapCommand = new DeviceTappedCommand(accountId, bank, "rail"); var accountSpy = new AccountSpy(); var container = new WindsorContainer(); container.AddFacility <SubstituterFacility>(config => { config.WithContainer(container) .Substitute <IAccount>(sub => sub.Instance(accountSpy)); }); container.Install(new InstallDevices()); var handleDevice = container.Resolve <HandleDevice>(); handleDevice.Handle(firstBankTapCommand); handleDevice.Handle(secondBankTapCommand); var projection = accountSpy.Get(accountId).Project(); Assert.That(projection.OriginDestination, Is.EqualTo(OriginDestination.HereToHere(bank))); Assert.That(projection.Fare, Is.EqualTo(5)); container.Release(handleDevice); }
public short GetFare(OriginDestination originDestination, string mode) { var network = _networks .OfType <ISatisfyMode>() .SingleOrDefault(m => m.Matches(mode)) as INetwork ?? new InvalidMode(_networks); return(network.GetFare(originDestination, mode)); }
public short GetFare(OriginDestination originDestination, string mode) { var network = _networks .OfType<ISatisfyMode>() .SingleOrDefault(m => m.Matches(mode)) as INetwork ?? new InvalidMode(_networks); return network.GetFare(originDestination, mode); }
internal void AssignFare(Fares fares) { var originDestination = GetOriginDestination(); if (OriginDestination.HasNoJourney(originDestination)) { return; } _fare = fares(originDestination); }
public void should_have_no_fare() { const short fare = 10; var journey = new Journey(); journey.AssignFare(od => fare); Assert.That(OriginDestination.HasNoJourney(journey.Project().OriginDestination), Is.True); Assert.That(journey.Project().Fare, Is.EqualTo(0)); }
public short GetFare(OriginDestination originDestination, string mode) { const string format = "Cannot match {0} against {1} for origin destination {2}"; var networks = string.Join(Environment.NewLine, _networks.Select(n => n.GetType().FullName)); var message = string.Format(format, mode, networks, originDestination); Console.WriteLine(message); return 0; }
public short GetFare(OriginDestination originDestination, string mode) { const string format = "Cannot match {0} against {1} for origin destination {2}"; var networks = string.Join(Environment.NewLine, _networks.Select(n => n.GetType().FullName)); var message = string.Format(format, mode, networks, originDestination); Console.WriteLine(message); return(0); }
void Start() { currentOriginDestination = new OriginDestination(); speed = 0.08f; currentOriginDestination.currentDestinationIndex = 0; _transform = gameObject.transform; currentOriginDestination.currentDestinationIndex = 0; currentGoalIndex = 1; currentGoal = _transform.position; }
public short GetFare(OriginDestination originDestination, string mode) { switch (mode) { case "rail": return 10; case "bus": return 2; default: throw new InvalidOperationException($"Cannot get fare for mode {mode}"); } }
public short GetFare(OriginDestination originDestination, string mode) { switch (mode) { case "rail": return(10); case "bus": return(2); default: throw new InvalidOperationException($"Cannot get fare for mode {mode}"); } }
public short GetFare(OriginDestination originDestination, string mode) { if (mode == "rail") { return(10); } if (mode == "bus") { return(2); } throw new InvalidOperationException($"Cannot get fare for mode {mode}"); }
private OriginDestination GetOriginDestination() { var origin = _origin(_taps); var destination = _destination(_taps) ?? origin; if (null == origin && null == destination) { return(OriginDestination.NoJourney()); } var originDestination = OriginDestination.OriginToDestination(origin.Location, destination.Location); return(originDestination); }
public short GetFare(OriginDestination originDestination, string mode) { if (mode == "rail") { return 10; } if (mode == "bus") { return 2; } throw new InvalidOperationException($"Cannot get fare for mode {mode}"); }
public short GetFare(OriginDestination originDestination, string mode) { var map = new Dictionary<string, Func<OriginDestination, short>> { {"rail", od => 10}, {"bus", od => 10} }; if (map.ContainsKey(mode)) { return map[mode](originDestination); } throw new InvalidOperationException($"Cannot get fare for mode {mode}"); }
public short GetFare(OriginDestination originDestination, string mode) { var map = new Dictionary <string, Func <OriginDestination, short> > { { "rail", od => 10 }, { "bus", od => 10 } }; if (map.ContainsKey(mode)) { return(map[mode](originDestination)); } throw new InvalidOperationException($"Cannot get fare for mode {mode}"); }
public async Task Test1() { var couple = new OriginDestination(AmsIata, BudIata); var service = new DistanceMeasurementService(this.placeInfoProviderMock.Object); this.SetupPlaceInfoProviderGetPlaceInfoAsyncMethod(AmsIata, new IataPoint(AmsIata, new Location(AmsLatitude, AmsLongitude))); this.SetupPlaceInfoProviderGetPlaceInfoAsyncMethod(BudIata, new IataPoint(BudIata, new Location(BudLatitude, BudLongitude))); var serviceResponse = await service.GetDistanceAsync(couple, CancellationToken.None); serviceResponse.IsFailure.Should().BeFalse(); serviceResponse.Value.Should().Be(AsmBudDistance); }
public async Task Test2() { var incorrectIata = this.fixture.Create <string>(); var couple = new OriginDestination(AmsIata, incorrectIata); var service = new DistanceMeasurementService(this.placeInfoProviderMock.Object); this.SetupPlaceInfoProviderGetPlaceInfoAsyncMethod(AmsIata, new IataPoint(AmsIata, new Location(AmsLatitude, AmsLongitude))); this.SetupPlaceInfoProviderGetPlaceInfoAsyncMethod(incorrectIata, Result.Failure <IataPoint>(this.fixture.Create <string>())); var serviceResponse = await service.GetDistanceAsync(couple, CancellationToken.None); serviceResponse.IsFailure.Should().BeTrue(); }
public void should_be_bank_to_bank() { const string bank = "Bank"; const short fare = 10; var journey = new Journey(); var msg1 = new DeviceTappedCommand(journey.AccountId, bank, "rail"); var msg2 = new DeviceTappedCommand(journey.AccountId, bank, "rail"); journey.RecieveTap(msg2); journey.RecieveTap(msg1); journey.AssignFare(od => fare); Assert.That(journey.Project().OriginDestination, Is.EqualTo(OriginDestination.HereToHere(bank))); Assert.That(journey.Project().Fare, Is.EqualTo(10)); }
public short GetFare(OriginDestination originDestination, string mode) { return 10; }
public short GetFare(OriginDestination originDestination, string mode) { return(5); }
void Start() { currentOriginDestination= new OriginDestination(); speed = 0.08f; currentOriginDestination.currentDestinationIndex = 0; _transform = gameObject.transform; currentOriginDestination.currentDestinationIndex = 0; currentGoalIndex = 1; currentGoal = _transform.position; }