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 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));
        }
예제 #3
0
        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 void should_be_sortable()
        {
            const string kingsCross = "Kings Cross";
            const string bank = "Bank";
            const string princeRegent = "Prince Regent";
            const short fare = 10;

            var accountId = Guid.NewGuid();

            var jny1 = new Journey(accountId, kingsCross, bank);
            var jny2 = new Journey(accountId, bank, princeRegent);
            var jny3 = new Journey(accountId, princeRegent, bank);

            jny1.AssignFare((o, d) => fare);
            jny2.AssignFare((o, d) => fare);
            jny3.AssignFare((o, d) => fare);

            var jourenys = new List<Journey>(new[] {jny2, jny3, jny1});
            jourenys.Sort();

            Assert.That(jourenys.First().Export().Origin, Is.EqualTo(kingsCross));
            Assert.That(jourenys.First().Export().Destination, Is.EqualTo(bank));
            Assert.That(jourenys.First().Export().Fare, Is.EqualTo(10));
            Assert.That(jourenys.First().Export().AccountId, Is.EqualTo(accountId));
            Assert.That(jourenys.First().Export().JourneyId, Is.Not.EqualTo(Guid.Empty));

            Assert.That(jourenys.ElementAt(1).Export().Origin, Is.EqualTo(bank));
            Assert.That(jourenys.ElementAt(1).Export().Destination, Is.EqualTo(princeRegent));
            Assert.That(jourenys.ElementAt(1).Export().Fare, Is.EqualTo(10));
            Assert.That(jourenys.ElementAt(1).Export().AccountId, Is.EqualTo(accountId));
            Assert.That(jourenys.ElementAt(1).Export().JourneyId, Is.Not.EqualTo(Guid.Empty));

            Assert.That(jourenys.Last().Export().Origin, Is.EqualTo(princeRegent));
            Assert.That(jourenys.Last().Export().Destination, Is.EqualTo(bank));
            Assert.That(jourenys.Last().Export().Fare, Is.EqualTo(10));
            Assert.That(jourenys.Last().Export().AccountId, Is.EqualTo(accountId));
            Assert.That(jourenys.Last().Export().JourneyId, Is.Not.EqualTo(Guid.Empty));
        }
        public void should_demonstrate_tinkering()
        {

            const string outerMongolia = "Outer Mongolia";
            const string bank = "Bank";
            const short fare = 10;

            var memento = new JourneyMemento
            {
                AccountId = Guid.NewGuid(),
                Origin = bank,
                Destination = bank,
                Fare = 0
            };

            var journey = new Journey(memento);
            memento.Destination = outerMongolia;
            journey.AssignFare((origin, destination) => fare);

            var projection = journey.Project();

            Assert.That(projection.Destination, Is.EqualTo(outerMongolia));
        }
        public void should_be_sortable()
        {
            const string bank = "Bank";
            const string princeRegent = "Prince Regent";
            const short fare = 10;

            var jny1Memento = new JourneyMemento
            {
                Origin = bank,
                Destination = princeRegent,
                Fare = 0
            };

            var jny2Memento = new JourneyMemento
            {
                Origin = princeRegent,
                Destination = bank,
                Fare = 0
            };

            var jny1 = new Journey(jny1Memento);
            var jny2 = new Journey(jny2Memento);

            jny1.AssignFare((o, d) => fare);
            jny2.AssignFare((o, d) => fare);

            var journeys = new List<Journey>(new[] {jny2, jny1});
            journeys.Sort();

            Assert.That(journeys.First().Project().Origin, Is.EqualTo(bank));
            Assert.That(journeys.First().Project().Destination, Is.EqualTo(princeRegent));
            Assert.That(journeys.First().Project().Fare, Is.EqualTo(10));

            Assert.That(journeys.Last().Project().Origin, Is.EqualTo(princeRegent));
            Assert.That(journeys.Last().Project().Destination, Is.EqualTo(bank));
            Assert.That(journeys.Last().Project().Fare, Is.EqualTo(10));
        }
        public void should_include_fields()
        {
            const string bank = "Bank";
            const short fare = 10;

            var memento = new JourneyMemento
            {
                AccountId = Guid.NewGuid(),
                Origin = bank,
                Destination = bank,
                Fare = 0
            };

            var journey = new Journey(memento);
            
            journey.AssignFare((origin, destination) => fare);

            var projection = journey.Project();

            Assert.That(projection.AccountId, Is.EqualTo(memento.AccountId));
            Assert.That(projection.Origin, Is.EqualTo(bank));
            Assert.That(projection.Destination, Is.EqualTo(bank));
            Assert.That(projection.Fare, Is.EqualTo(10));
        }