public void Pet(AnimalIdentifier animalIdentifier)
        {
            var animal = _animalFindService.GetByIdentifier(animalIdentifier);

            DateTime animalLastPettedAsDateTime = animal.LastPetted ?? DateTime.MinValue;

            if (animalLastPettedAsDateTime == DateTime.MinValue)
            {
                animal.Pet();
                animal.Happiness = (AnimalDataUtilities.HappinessConfig()[animal.Type]);
                return;
            }

            animal.Happiness = (animal.Happiness + AnimalDataUtilities.HappinessConfig()[animal.Type]);
            animal.Pet();
        }
Ejemplo n.º 2
0
            public void Repository_is_called_when_finding_a_Animal_by_AnimalIdentifier()
            {
                //arrange
                const string animalName = "ted";
                const string userId     = "*****@*****.**";
                var          repository = Substitute.For <IAnimalRepository>();
                var          service    = new VirtualPet.Services.AnimalFindService(repository);

                //act
                var identifier = new AnimalIdentifier(userId, animalName);

                service.GetByIdentifier(identifier);

                //assert
                repository.ReceivedWithAnyArgs().GetByUserIdandAnimalName(Arg.Any <string>(), Arg.Any <string>());
            }
Ejemplo n.º 3
0
 public IAnimal GetByIdentifier(AnimalIdentifier animal)
 {
     return(_animalRepository.GetByUserIdandAnimalName(animal.UserId, animal.AnimalName));
 }
Ejemplo n.º 4
0
 public HttpResponseMessage Pet(AnimalIdentifier animal)
 {
     _animalPettingService.Pet(animal);
     return(new HttpResponseMessage(HttpStatusCode.Accepted));
 }
Ejemplo n.º 5
0
 public HttpResponseMessage Feed(AnimalIdentifier identifier)
 {
     _animalFeedingService.Feed(identifier);
     return(new HttpResponseMessage(HttpStatusCode.Accepted));
 }
 public void Feed(AnimalIdentifier identifier)
 {
     _animalFindService.GetByIdentifier(identifier).Feed();
 }