public void Constructor_ShouldSetProperties() { var dut = new UpdateJourneyCommand(1, "TitleA", "AAAAAAAAABA="); Assert.AreEqual(1, dut.JourneyId); Assert.AreEqual("TitleA", dut.Title); Assert.AreEqual("AAAAAAAAABA=", dut.RowVersion); }
public void Setup_OkState() { _journeyValidatorMock = new Mock <IJourneyValidator>(); _journeyValidatorMock.Setup(r => r.ExistsAsync(_id, default)).Returns(Task.FromResult(true)); _command = new UpdateJourneyCommand(_id, _title, _rowVersion); _rowVersionValidatorMock = new Mock <IRowVersionValidator>(); _rowVersionValidatorMock.Setup(r => r.IsValid(_rowVersion)).Returns(true); _dut = new UpdateJourneyCommandValidator(_journeyValidatorMock.Object, _rowVersionValidatorMock.Object); }
public void Validate_ShouldFail_WhenInvalidRowVersion() { const string invalidRowVersion = "String"; var command = new UpdateJourneyCommand(_id, _title, invalidRowVersion); _rowVersionValidatorMock.Setup(r => r.IsValid(invalidRowVersion)).Returns(false); var result = _dut.Validate(command); Assert.IsFalse(result.IsValid); Assert.AreEqual(1, result.Errors.Count); Assert.IsTrue(result.Errors[0].ErrorMessage.StartsWith("Not a valid row version!")); }
public void Setup() { // Arrange var testJourneyId = 1; var journeyRepositoryMock = new Mock <IJourneyRepository>(); _journey = new Journey(TestPlant, _oldTitle); journeyRepositoryMock.Setup(j => j.GetByIdAsync(testJourneyId)) .Returns(Task.FromResult(_journey)); _command = new UpdateJourneyCommand(testJourneyId, _newTitle, _rowVersion); _dut = new UpdateJourneyCommandHandler( journeyRepositoryMock.Object, UnitOfWorkMock.Object); }