Пример #1
0
        public void Constructor_ShouldSetProperties()
        {
            var dut = new UnvoidJourneyCommand(2, "AAAAAAAAABA=");

            Assert.AreEqual(2, dut.JourneyId);
            Assert.AreEqual("AAAAAAAAABA=", dut.RowVersion);
        }
        public void Setup_OkState()
        {
            _journeyValidatorMock = new Mock <IJourneyValidator>();
            _journeyValidatorMock.Setup(r => r.ExistsAsync(_journeyId, default)).Returns(Task.FromResult(true));
            _journeyValidatorMock.Setup(r => r.IsVoidedAsync(_journeyId, default)).Returns(Task.FromResult(true));

            _rowVersionValidatorMock = new Mock <IRowVersionValidator>();
            _rowVersionValidatorMock.Setup(r => r.IsValid(_rowVersion)).Returns(true);

            _command = new UnvoidJourneyCommand(_journeyId, _rowVersion);
            _dut     = new UnvoidJourneyCommandValidator(_journeyValidatorMock.Object, _rowVersionValidatorMock.Object);
        }
        public void Validate_ShouldFail_WhenInvalidRowVersion()
        {
            const string invalidRowVersion = "String";

            var command = new UnvoidJourneyCommand(_journeyId, 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!"));
        }
Пример #4
0
        public void Setup()
        {
            var journeyId             = 2;
            var journeyRepositoryMock = new Mock <IJourneyRepository>();

            _journey = new Journey(TestPlant, "JourneyTitle");
            journeyRepositoryMock
            .Setup(r => r.GetByIdAsync(journeyId))
            .Returns(Task.FromResult(_journey));

            _command = new UnvoidJourneyCommand(journeyId, _rowVersion);

            _dut = new UnvoidJourneyCommandHandler(
                journeyRepositoryMock.Object,
                UnitOfWorkMock.Object);
        }