I'm getting strange results that I don't understand. Either of these unit tests will pass when run individually:
[Isolated, TestMethod, Owner("Mark Phillips"), TestCategory("Default Replenishment Information")]
public void UpdateDefaultReplenishmentByStockTypeId_CaseQuantityTooLow_ExpectValidationError()
{
//Arrange
string expectedError = "Case quantity must be 1 or greater.";
Isolate.NonPublic.WhenCalled<ProductReplenishmentData>("StockTypeIdIsValid").IgnoreCall();
ProductReplenishmentDefaults defaults = ProductReplenishmentDefaults.NewReplenishmentItemDefaults();
ProductReplenishmentData productReplenishmentData = ProductReplenishmentData.NewReplenishmentItemForDefaultsList(defaults, true);
//Act
productReplenishmentData.CaseQuantity = 0;
//Assert
Assert.IsFalse(productReplenishmentData.IsValid);
Assert.AreEqual<string>(expectedError, productReplenishmentData.BrokenRulesCollection.ToString().StripErrorCode());
}
[Isolated, TestMethod, Owner("Mark Phillips"), TestCategory("Default Replenishment Information")]
public void UpdateDefaultReplenishmentByStockTypeId_CaseQuantityEdgeValue_ExpectValid()
{
//Arrange
Isolate.NonPublic.WhenCalled<ProductReplenishmentData>("StockTypeIdIsValid").IgnoreCall();
ProductReplenishmentDefaults defaults = ProductReplenishmentDefaults.NewReplenishmentItemDefaults();
ProductReplenishmentData productReplenishmentData = ProductReplenishmentData.NewReplenishmentItemForDefaultsList(defaults, true);
//Act
productReplenishmentData.CaseQuantity = 1;
//Assert
Assert.IsTrue(productReplenishmentData.IsValid);
}
But when run together the second one fails with System.InvalidOperationException: Cannot register property CaseQuantity after containing type (ProductReplenishmentData) has been instantiated.
Both methods have the Isolated attribute, so why would the results be different when run individually versus together?
I am using version 6.0.10.0.
Thanks,
Mark