コード例 #1
0
        public void UnFavouriteFoodItem(string personReference, int sku)
        {
            var person   = personRepository.FindPersonWithReference(PersonReference.FromExisting(personReference));
            var foodItem = foodItemRepository.FindFoodItemWithSku(sku);

            person.UnFavorite(foodItem);
            personRepository.Save(person);
        }
コード例 #2
0
        public void FavoritingAnItemShouldRaiseAnEvent()
        {
            var person   = new Person(PersonReference.FromExisting("ref-001"), "Homer");
            var foodItem = new FoodItem(7463928, "Extra Strong Concentrated Squishee Syrup");
            PersonFavoritedFoodItemEvent raisedEvent = null;

            DomainEvents.Register <PersonFavoritedFoodItemEvent>((obj) => raisedEvent = (obj));

            person.Favorite(foodItem);

            Assert.IsInstanceOf(typeof(PersonFavoritedFoodItemEvent), raisedEvent);
            Assert.AreEqual(person, raisedEvent.Person);
            Assert.AreEqual(foodItem, raisedEvent.FoodItem);
        }
コード例 #3
0
 public void GivenIHaveAPersonWithTheReferenceNamed(string reference, string name)
 {
     this.people.Add(reference, new Person(PersonReference.FromExisting(reference), name));
 }
コード例 #4
0
 public InMemoryPersonRepository()
 {
     people.Add(new Person(PersonReference.FromExisting("ref-001"), "James"));
 }