public void TestInterface() { Mallard duck = new Mallard(); Assert.True(duck.Migrates); Assert.False(duck.BreathesUnderWater); }
public void IFlyTestDuck() { // Arrange and Act Mallard mallard = new Mallard(); MandarinDuck mandarinDuck = new MandarinDuck(); //Assert Assert.False(mallard.BarrelRoll() && mandarinDuck.BarrelRoll()); }
public void ISwimTestDuck() { // Arrange and Act Mallard mallard = new Mallard(); MandarinDuck mandarinDuck = new MandarinDuck(); //Assert Assert.Equal("quack-quack-quack", mallard.Sing()); Assert.Equal("quack-quack-quack", mandarinDuck.Sing()); }
static void Main(string[] args) { Wolf theWolf = new Wolf(); dynamic theDuck = theWolf; // Not necessary. Duck aDuck = new Mallard(); twoDucksAlone(aDuck, theDuck); System.Console.WriteLine(theWolf.eat(aDuck)); }
static void Main(string[] args) { BlackWidow charlotte = new BlackWidow(); charlotte.name = "charlotte"; Eagle ernest = new Eagle(); ernest.name = "ernest"; GrizzlyBear willis = new GrizzlyBear(); willis.name = "willis"; HumpbackWhale karl = new HumpbackWhale(); karl.name = "karl"; Mallard cheryl = new Mallard(); cheryl.name = "cheryl"; SiberianTiger goliath = new SiberianTiger(); goliath.name = "goliath"; Console.WriteLine($"Helo my name is {goliath.name}"); Console.WriteLine(goliath.Reproduction(goliath.reproduction)); Console.WriteLine(goliath.Diet(goliath.diet)); Console.WriteLine("\n"); Console.WriteLine($"Helo my name is {cheryl.name}"); Console.WriteLine(cheryl.Reproduction(cheryl.reproduction)); Console.WriteLine(cheryl.Diet(cheryl.diet)); Console.WriteLine("\n"); Console.WriteLine($"Helo my name is {karl.name}"); Console.WriteLine(karl.Reproduction(karl.reproduction)); Console.WriteLine(karl.Diet(karl.diet)); Console.WriteLine("\n"); Console.WriteLine($"Helo my name is {willis.name}"); Console.WriteLine(willis.Reproduction(willis.reproduction)); Console.WriteLine(willis.Diet(willis.diet)); Console.WriteLine("\n"); Console.WriteLine($"Helo my name is {ernest.name}"); Console.WriteLine(ernest.Reproduction(ernest.reproduction)); Console.WriteLine(ernest.Diet(ernest.diet)); Console.WriteLine("\n"); Console.WriteLine($"Helo my name is {charlotte.name}"); Console.WriteLine(charlotte.Legs(charlotte.legCount)); Console.WriteLine(charlotte.Exterior(charlotte.exterior, charlotte.segmentedBody)); Console.WriteLine("\n"); Console.WriteLine("Thank you come again!"); Console.Read(); }
public void QuackTest() { var mallard = new Mallard(); var darkwingDuck = new DarkwingDuck(); var toy = new DarkwingDuckToy(); Assert.Equal(mallard.Quack(), Quack(mallard)); Assert.Equal(darkwingDuck.Quack(), Quack(darkwingDuck)); Assert.Throws <Exception>(() => toy.Quack()); toy.InsertBatteries(); Assert.Equal(toy.Quack(), Quack(toy)); }
public void Mallard_can_quack() { // Arrange var duckUnderTest = new Mallard(); // Act var result = duckUnderTest.Quack(); // Asset Assert.That(result, Is.EqualTo("Quack!")); }
public void Mallard_can_change_quack_to_muted() { // Arrange var duckUnderTest = new Mallard(); duckUnderTest.QuackBehaviour = new MutedQuack(); // Act var result = duckUnderTest.Quack(); // Assert Assert.That(result, Is.EqualTo("...")); }
static void Main(string[] args) { Console.WriteLine("Mallard"); Mallard mallard = new Mallard(); Helper(mallard); Console.WriteLine("Spaniel"); Spaniel spaniel = new Spaniel(); Helper(spaniel); Console.WriteLine("Progeny"); Spaniel progeny = new Spaniel(); progeny.SetQuack(new QuackLikeMallard()); Helper(progeny); Console.ReadLine(); }
static void Main(string[] args) { Console.ReadKey(); BehaviorFactory duckBehaviorFactory = new BehaviorFactory(); Flock flock = new Flock(); Duck mallard = new Mallard(flock, duckBehaviorFactory); Duck sicklyDuck = new SicklyDuck(flock, duckBehaviorFactory); Duck rubberDuck = new RubberDuck(flock, duckBehaviorFactory); flock.Attach(mallard); flock.Attach(sicklyDuck); flock.Attach(rubberDuck); DuckStory(flock, rubberDuck, sicklyDuck, duckBehaviorFactory); Console.WriteLine("\r\n" + "Thanks for learning!" + "\r\n"); Console.ReadLine(); }
/// <summary> /// This just tests that the classes inherit properties /// </summary> static void Proof() { ChannelCatfish channelCatfish = new ChannelCatfish(); FlatheadCatfish flatheadCatfish = new FlatheadCatfish(); TigerShark tigerShark = new TigerShark(); GreatWhiteShark greatWhiteShark = new GreatWhiteShark(); EmperorPenguin emperorPenguin = new EmperorPenguin(); GalapagosPenguin galapagosPenguin = new GalapagosPenguin(); Mallard mallard = new Mallard(); MandarinDuck mandarinDuck = new MandarinDuck(); PrairieFalcon prairieFalcon = new PrairieFalcon(); Gyrfalcon gyrfalcon = new Gyrfalcon(); Dragon dragon = new Dragon(); KomodoDragon komodoDragon = new KomodoDragon(); Anaconda anaconda = new Anaconda(); Rattlesnake rattlesnake = new Rattlesnake(); Dhole dhole = new Dhole(); TundraWolf tundraWolf = new TundraWolf(); HouseCat houseCat = new HouseCat(); Jaguar jaguar = new Jaguar(); Console.WriteLine($"channel catfish gets food: {channelCatfish.FoodAquisition()}"); Console.WriteLine($"flathead catfish habitat: {flatheadCatfish.Habitat}"); Console.WriteLine($"great white shark cares for young?: {greatWhiteShark.CaresForYoung}"); Console.WriteLine($"tiger shark move: {tigerShark.FastestMovement()}"); Console.WriteLine($"emperor penguin swims?: {emperorPenguin.Sing()}"); Console.WriteLine($"galapagos penguin moves: {galapagosPenguin.FastestMovement()}"); Console.WriteLine($"mallard sound: {mallard.Sound()}"); Console.WriteLine($"mandarin duck does barrel roll?: {mandarinDuck.BarrelRoll()}"); Console.WriteLine($"gyrfalcon does barrel roll?: {gyrfalcon.BarrelRoll()}"); Console.WriteLine($"prairie falcon sound: {prairieFalcon.Sound()}"); Console.WriteLine($"dragon does barrel roll?: {dragon.BarrelRoll()}"); Console.WriteLine($"komodo dragon birth: {komodoDragon.Birth()}"); Console.WriteLine($" anaconda swims?: {anaconda.Sing()}"); Console.WriteLine($" rattlesnake gets food: {rattlesnake.FoodAquisition()}"); Console.WriteLine($"dhole gets food: {dhole.FoodAquisition()}"); Console.WriteLine($"dhole birth: {dhole.Birth()}"); Console.WriteLine($"tundra wolf move: {tundraWolf.FastestMovement()}"); Console.WriteLine($"house cat gets food: {houseCat.FoodAquisition()}"); Console.WriteLine($"jaguar can climb?: {jaguar.CanClimb}"); }
private void typeduck_SelectedIndexChanged(object sender, EventArgs e) { dis(); Iduck iduck; switch (typeduck.SelectedIndex) { case 0: iduck = new Mallard(); iduck.TypeDuck(lblQ, lblfly, lblN, duckPic); break; case 1: { iduck = new Toy(); iduck.TypeDuck(lblQ, lblfly, lblN, duckPic); break; } case 2: iduck = new Decoy(); iduck.TypeDuck(lblQ, lblfly, lblN, duckPic); break; case 3: iduck = new Rubber(); iduck.TypeDuck(lblQ, lblfly, lblN, duckPic); break; case 4: iduck = new RedHead(); iduck.TypeDuck(lblQ, lblfly, lblN, duckPic); break; } }
public void MallardTest() { Mallard mallard = new Mallard(); Assert.Equal("I eat fish eggs fish worms mollusk .", mallard.Eat(mallard.diet)); }