public void CantUpdateNonExistingPosition() { var position = new DTOPosition(3, "1", "1"); var positionListStub = new PositionListStub(); var positionListValidator = new PositionListValidator(positionListStub); string error = null; EventHandler <PositionListChangedEventArgs> handler = (sender, e) => error = e.Error; positionListValidator.PositionListChanged += handler; positionListValidator.LoadPositionList(); positionListValidator.UpdatePosition(position); Assert.AreEqual("Position 1 cannot be found", error); }
public void CanUpdateCategoryOnly() { var position = new DTOPosition(2, "2", "1"); var positionListStub = new PositionListStub(); var positionListValidator = new PositionListValidator(positionListStub); string error = null; EventHandler <PositionListChangedEventArgs> handler = (sender, e) => error = e.Error; positionListValidator.PositionListChanged += handler; positionListValidator.LoadPositionList(); positionListValidator.UpdatePosition(position); Assert.IsNull(error); }
public void CantUpdateToExistingName() { var position = new DTOPosition(2, "1", "1"); var positionListStub = new PositionListStub(); var positionListValidator = new PositionListValidator(positionListStub); string error = null; EventHandler <PositionListChangedEventArgs> handler = (sender, e) => error = e.Error; positionListValidator.PositionListChanged += handler; positionListValidator.LoadPositionList(); positionListValidator.UpdatePosition(position); Assert.AreEqual("Name 1 is already taken", error); }
public void UpdatePositionMethod_InvokesDependencyAddPositionMethod_IfPositionPassesValidation() { var position = new DTOPosition(1, "1", "1"); var positionListStub = new PositionListStub(); bool invoked = false; EventHandler <PositionListChangedEventArgs> handler = (sender, e) => invoked = true; positionListStub.PositionListChanged += handler; var positionListValidator = new PositionListValidator(positionListStub); positionListValidator.LoadPositionList(); positionListValidator.UpdatePosition(position); Assert.IsTrue(invoked); }