public Repr.Waypoint To(
                int reverseAuctionId,
                Repr.Waypoint newPickup)
            {
                newPickup.MustNotBeNull(nameof(newPickup));

                // This assertion knows too much about underlying details.
                // It seems like another clue that we need a Domain Value Type
                // that represents a ReverseAuctionIdentifier.
                //reverseAuctionId.MustBePositive(nameof(reverseAuctionId));

                var auction = _repository.Get(reverseAuctionId);

                // TODO: There's a substantial, intentional mismatch bettween
                // the coarser API Waypoint resource and the finer-grained
                // Domain Waypoint, Location, and TimeRange concepts.  Right
                // now, only changes to the location are allowed.  Pickup
                // TimeRange changes should be allowed, but require both more
                // business logic and some thought about how the two fit
                // together.
                ThrowIfPickupTimeRangeHasChanged(auction, newPickup);

                auction.AlterPickup(
                    _dependencies,
                    newPickup.Address);

                _repository.Update(auction);
                return(Convert.ToRepr(auction.BuyerTerms.Pickup));
            }
        public void SmokeTest()
        {
            // Arrange
            var now = _fakeClock.Now.ToIso8601();
            var fiveMinutesHence = _fakeClock.Now.AddMinutes(5).ToIso8601();
            var oneHourHence     = _fakeClock.Now.AddHours(1).ToIso8601();

            var geocoder = (FakeGeocoder)Container.GetInstance <IGeocoder>();

            geocoder["original"] = Austin;
            geocoder["changed"]  = Seattle;

            var aggregate = NewAuctionWithPickup("original");

            _fakeRepository.Saved = aggregate;

            var expected = new Repr.Waypoint
            {
                Address  = "changed",
                Earliest = now,
                Latest   = oneHourHence,
            };

            // Act
            var alterPickup = Container.GetInstance <ReverseAuction.AlterPickup>();
            var actual      = alterPickup.To(aggregate.Id, expected);

            // Assert
            Assert.AreEqual(
                "changed",
                aggregate.BuyerTerms.Pickup.Place.Address);
            Assert.AreEqual(
                geocoder["changed"],
                aggregate.BuyerTerms.Pickup.Place.Coordinates);
        }
            /// <summary>EXPOSED FOR UNIT TESTING ONLY</summary>
            internal void ThrowIfPickupTimeRangeHasChanged(
                ReverseAuctionAggregate auction,
                Repr.Waypoint newPickup)
            {
                var current   = auction.BuyerTerms.Pickup.Time;
                var requested = Convert.ToTimeRange(newPickup.Earliest, newPickup.Latest);

                if (current != requested)
                {
                    throw new ArgumentException("cannot change pickup time");
                }
            }
示例#4
0
        internal static TimeRange FromRepr(this Repr.Waypoint w)
        {
            w.MustNotBeNull(nameof(w));

            return(ToTimeRange(w.Earliest, w.Latest));
        }