public void PropertyUsageDescriptionTest() { //Arrange string info = "OLW"; string expectedNullUsageDescription = "Unknown usage"; string initialDefaultDescription = "Eat the popcorn and have fun!"; int price = 20; var popcorn = new PopCorn(price, info, info); //Act string initialDescr = popcorn.UsageDescription; //what is set by constructor popcorn.UsageDescription = null; string nullDescr = popcorn.UsageDescription; popcorn.UsageDescription = ""; string emptyDescr = popcorn.UsageDescription; popcorn.UsageDescription = info; string changedDescr = popcorn.UsageDescription; string usageDescriptionFromUse = popcorn.Use(); //Assert Assert.Equal(initialDefaultDescription, initialDescr); Assert.Equal(expectedNullUsageDescription, nullDescr); Assert.Equal(expectedNullUsageDescription, emptyDescr); Assert.Equal(info, changedDescr); Assert.Equal(info, usageDescriptionFromUse); }
public void MethodUseTest() { //Arrange var popcorn = new PopCorn(900, "OLW", "Info"); string expectedInitialUsage = "Eat the popcorn and have fun!"; string expectedChangedUsage = "Updated usage"; //Act string receivedIntialUsage = popcorn.Use(); popcorn.UsageDescription = expectedChangedUsage; //Assert Assert.Equal(expectedInitialUsage, receivedIntialUsage); Assert.Equal(expectedChangedUsage, popcorn.Use()); }
public void NormalConstructorCheckAllMethodsTest() { //Arrange string name = "OLW"; string info = "500 g"; string usage = "Eat the popcorn and have fun!"; int price = 18; //Act var pop1 = new PopCorn(price, name, info); string examineString = pop1.Examine(); string usageString = pop1.Use(); //Assert //check Examine method Assert.Contains(name, examineString); Assert.Contains(info, examineString); Assert.Contains(price.ToString(), examineString); //check Use method Assert.Contains(usage, usageString); }