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 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_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 Handle(DeviceTappedCommand deviceTappedCommand) { var jny = _account.Get(deviceTappedCommand.AccountId); jny.RecieveTap(deviceTappedCommand); jny.AssignFare(od => _network.GetFare(od, deviceTappedCommand.Mode)); _account.Store(jny); }
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)); }