Esempio n. 1
0
 public void PetWasSold(Pet pet)
 {
     // Mimics adding to a real database
     new Thread(() =>
     {
         Thread.Sleep(400);
         pet.Sold = true;
         _unsoldPets.Remove(pet);
         _events.GetEvent<SoldPetEvent>().Publish(pet);
     }).Start();
 }
        public void CreatePetRepository()
        {
            _goldie = new Pet
                          {
                              Name = "Goldie",
                              FoodType = PetFood.ALL[3],
                              PriceInPence = 10000,
                              Rules = new List<Rule>{Rule.SELL_IN_PAIRS},
                              Sold = true,
                              Type = new PetType("Carp")
                          };

            _petRepository = new Mock<ILookAfterPets>();
            _petRepository.SetupGet(pr => pr.Pets).Returns(new List<Pet> {_goldie});
        }
Esempio n. 3
0
        public void Save(Pet pet)
        {
            string petType = (pet.Type == null) ? string.Empty : pet.Type.Name;
            string petFood = (pet.FoodType == null) ? string.Empty : pet.FoodType.Text;
            _history.AddText(string.Format("{0} the {1} registered at a price of £{2}. Food: {3}", pet.Name, petType,
                                           pet.Price, petFood));

            // Mimics adding to a real database
            new Thread(() =>
                           {
                               Thread.Sleep(400);
                               _pets.Add(pet);
                               _unsoldPets.Add(pet);
                               _events.GetEvent<NewPetEvent>().Publish(pet);
                           }).Start();
        }