コード例 #1
0
        public void Constructor_ShouldSetProperties()
        {
            var dut = new VoidModeCommand(1, "AAAAAAAAABA=");

            Assert.AreEqual(1, dut.ModeId);
            Assert.AreEqual("AAAAAAAAABA=", dut.RowVersion);
        }
        public void Setup_OkState()
        {
            _modeValidatorMock = new Mock <IModeValidator>();
            _modeValidatorMock.Setup(r => r.ExistsAsync(_modeId, default)).Returns(Task.FromResult(true));

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

            _command = new VoidModeCommand(_modeId, _rowVersion);
            _dut     = new VoidModeCommandValidator(_modeValidatorMock.Object, _rowVersionValidatorMock.Object);
        }
        public void Validate_ShouldFail_WhenInvalidRowVersion()
        {
            const string invalidRowVersion = "String";

            var command = new VoidModeCommand(_modeId, 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()
        {
            // Arrange
            var modeId             = 1;
            var modeRepositoryMock = new Mock <IModeRepository>();

            _mode = new Mode(TestPlant, "ModeTitle", false);
            _mode.SetProtectedIdForTesting(modeId);

            modeRepositoryMock.Setup(m => m.GetByIdAsync(modeId))
            .Returns(Task.FromResult(_mode));

            _command = new VoidModeCommand(modeId, _rowVersion);

            _dut = new VoidModeCommandHandler(
                modeRepositoryMock.Object,
                UnitOfWorkMock.Object);
        }