public void Test_Validate_False() { MockInvalidEntity entity = new MockInvalidEntity(); bool isValid = ValidateStrategy.New(entity).Validate(entity); Assert.IsFalse(isValid, "Returned true when it should have been false"); }
public void Test_Save_InvalidEntityMustNotSave() { // Create the mock entity MockInvalidEntity entity = new MockInvalidEntity(); entity.Validator = new ValidateStrategy(); Assert.IsFalse(entity.IsValid, "The validator returned true when it should return false."); // Try to save the entity bool isValid = SaveStrategy.New(entity, false).Save(entity); // Ensure that the save was rejected Assert.IsFalse(isValid, "The save strategy didn't recognise the entity as invalid."); // Try loading the entity from the data store to see if it's found MockInvalidEntity foundEntity = RetrieveStrategy.New<MockInvalidEntity>(false).Retrieve<MockInvalidEntity>("ID", entity.ID); // Ensure the entity wasn't found and therefore wasn't saved Assert.IsNull(foundEntity, "The entity was found in the store even though it shouldn't have saved."); }