public void ThrowOverflowException_WhenCommandIsInCorrectFormat_ButAnyValuesOfResourceAmountIsLargerThanUintMaxValue() { var resourcesParameters = new IntergalacticTravel.ResourcesFactory(); var command = "create resources silver(555555555555555555555555555555555) gold(97853252356623523532999999999) bronze(20)"; Assert.Throws <OverflowException>(() => resourcesParameters.GetResources(command)); }
public void ThrowInvalidOperationExceptionWhichContainsCommand_WhenInputStringRepresentsInvalidCommand() { var resourcesParameters = new IntergalacticTravel.ResourcesFactory(); var command = "tansta resources a b"; Assert.Throws <InvalidOperationException>(() => resourcesParameters.GetResources(command)); }
public void ThrowOverflowException_WhenTheInputStringRepresentsValidCommandButAnyOfTheValuesThatRepresentTheResourceAmountIsLargerThanTheMaximumValueAllowed(string command) { // Arrange var resourcesFactory = new IntergalacticTravel.ResourcesFactory(); // Act & Assert Assert.Throws <OverflowException>( () => resourcesFactory.GetResources(command)); }
public void ReturnNewlyCreatedResources_WithCorrectlySetProperties() { var resourcesParameters = new IntergalacticTravel.ResourcesFactory(); var command = "create resources gold(20) silver(30) bronze(40)"; Assert.AreEqual(20, resourcesParameters.GetResources(command).GoldCoins); Assert.AreEqual(30, resourcesParameters.GetResources(command).SilverCoins); Assert.AreEqual(40, resourcesParameters.GetResources(command).BronzeCoins); }
public void ThrowInvalidOperationExceptionWhichContainsTheStringCommand_WhenTheInputStringRepresentsInvalidCommand(string invalidCommand) { // Arrange var resourcesFactory = new IntergalacticTravel.ResourcesFactory(); var expectedExceptionMessage = "command"; // Act & Assert var exc = Assert.Throws <InvalidOperationException>( () => resourcesFactory.GetResources(invalidCommand)); var actualExceptionMessage = exc.Message; // Assert StringAssert.Contains(expectedExceptionMessage, actualExceptionMessage); }
public void ReturnNewResourcesWithCorrectlySetUpProperties_WhenTheCommandPassedIsValid_NoMatterWhatIsTheOrderOfTheParameters(string command) { // Arrange var expectedBronzeCoinsAmount = 40; var expectedSilverCoinsAmount = 30; var expectedGoldCoinsAmount = 20; var resourcesFactory = new IntergalacticTravel.ResourcesFactory(); // Act var actualResourcesAmount = resourcesFactory.GetResources(command); // Assert Assert.AreEqual(expectedBronzeCoinsAmount, actualResourcesAmount.BronzeCoins); Assert.AreEqual(expectedSilverCoinsAmount, actualResourcesAmount.SilverCoins); Assert.AreEqual(expectedGoldCoinsAmount, actualResourcesAmount.GoldCoins); }