public void ExampleOfUse() { // Dragon is born and it is a baby var dragon = new Tamagotchi("Needy dragon"); var needForFood = new FoodNeeds(); var needForPetting = new PettingNeeds(); dragon.AddNeed(needForFood); dragon.AddNeed(needForPetting); // TimePassed could be called each hour (or something like that) to age the pet dragon.TimePassed(); dragon.TimePassed(); dragon.TimePassed(); // At this point it is 3 years old, very unhappy and hungry dragon.Age.ShouldBe(3); dragon.Happiness.ShouldBe(-45); dragon.Hungriness.ShouldBe(24); // Let's feed it first dragon.Feed(); dragon.Feed(); dragon.Hungriness.ShouldBe(8); // It is less hungy now // Let's give it some attention dragon.Pet(); dragon.Pet(); dragon.Happiness.ShouldBe(-15); // It is less unhappy now // At this point we could add a new need. For example the need for a diet (Implemented bellow) dragon.AddNeed(new DietNeeds()); dragon.Weight.ShouldBe(7); // 50 years passed for (int i = 0; i < 50; i++) { dragon.TimePassed(); } dragon.Age.ShouldBe(53); dragon.Weight.ShouldBe(107); }
public void PettingYourDragonMakesThemHappy(Tamagotchi dragon, int happinessBefore, int happinessAfter) { "Given a dragon with petting needs".x(() => { dragon = new Tamagotchi("Dragon"); dragon.AddNeed(new PettingNeeds()); happinessBefore = dragon.Happiness; }); "When you pet it".x(() => { dragon.Pet(); happinessAfter = dragon.Happiness; }); "Then the dragon is more happy".x(() => { happinessAfter.ShouldBeGreaterThan(happinessBefore); }); }
public void FeedingYourDragonMakesThemLessHungry(Tamagotchi dragon, int hungrinessBefore, int hungrinessAfter) { "Given a dragon with food needs".x(() => { dragon = new Tamagotchi("Dragon"); dragon.AddNeed(new FoodNeeds()); hungrinessBefore = dragon.Hungriness; }); "When you feed it".x(() => { dragon.Feed(); hungrinessAfter = dragon.Hungriness; }); "Then the dragon is less hungry".x(() => { hungrinessAfter.ShouldBeLessThan(hungrinessBefore); }); }
public void DragonsHappinessDecreasesOverTime(Tamagotchi dragon, int happinessBefore, int happinessAfter) { "Given a dragon with petting needs".x(() => { dragon = new Tamagotchi("Dragon"); dragon.AddNeed(new PettingNeeds()); happinessBefore = dragon.Happiness; }); "When time passes without attention".x(() => { dragon.TimePassed(); happinessAfter = dragon.Happiness; }); "Then the dragon is less happy".x(() => { happinessAfter.ShouldBeLessThan(happinessBefore); }); }
public void DragonsHungerIncreasesOverTime(Tamagotchi dragon, int hungrinessBefore, int hungrinessAfter) { "Given a dragon with food needs".x(() => { dragon = new Tamagotchi("Dragon"); dragon.AddNeed(new FoodNeeds()); hungrinessBefore = dragon.Hungriness; }); "When time passes without food".x(() => { dragon.TimePassed(); hungrinessAfter = dragon.Hungriness; }); "Then the dragon is more hungry".x(() => { hungrinessAfter.ShouldBeGreaterThan(hungrinessBefore); }); }