Is it OK to mix Assert and Act steps? Is AAA more of a guideline than a rule? Or am I missing something?
Here is my test:
[TestMethod]
public void CancelButtonSelected_DontCancelTwiceThenCancel_DialogCloses()
{
// Arrange
IAddAddressForm form = Substitute.For<IAddAddressForm>();
// Indicate that when Show CancelMessage is called it
// should return cancel twice (saying we want to cancel the cancel)
// then it should return ok
form.ShowCancelMessage().Returns(DialogResult.Cancel,
DialogResult.Cancel, DialogResult.OK);
AddAddressController controller = new AddAddressController(form);
AddressItem item = TestHelper.CreateAddressBob();
// Act
EnterAddressInfo(form, controller, item);
controller.CancelButtonSelected();
Assert.IsTrue(form.DialogResult == DialogResult.None);
controller.CancelButtonSelected();
Assert.IsTrue(form.DialogResult == DialogResult.None);
controller.CancelButtonSelected();
// Assert
Assert.IsTrue(form.DialogResult == DialogResult.Cancel);
}
So I call a method 3 times. After each call, I want to make sure that we did not really cancel the dialog. Then on the third call, the dialog should be canceled.
Is this "legal" use of AAA syntax/styling?