public void Constructor_ShouldSetProperties() { var dut = new UnvoidRequirementTypeCommand(1, "AAAAAAAAABA="); Assert.AreEqual(1, dut.RequirementTypeId); Assert.AreEqual("AAAAAAAAABA=", dut.RowVersion); }
public void Setup_OkState() { _reqTypeValidatorMock = new Mock <IRequirementTypeValidator>(); _reqTypeValidatorMock.Setup(r => r.ExistsAsync(_requirementTypeId, default)).Returns(Task.FromResult(true)); _reqTypeValidatorMock.Setup(r => r.IsVoidedAsync(_requirementTypeId, default)).Returns(Task.FromResult(true)); _rowVersionValidatorMock = new Mock <IRowVersionValidator>(); _rowVersionValidatorMock.Setup(r => r.IsValid(_rowVersion)).Returns(true); _command = new UnvoidRequirementTypeCommand(_requirementTypeId, _rowVersion); _dut = new UnvoidRequirementTypeCommandValidator(_reqTypeValidatorMock.Object, _rowVersionValidatorMock.Object); }
public void Validate_ShouldFail_WhenInvalidRowVersion() { const string invalidRowVersion = "String"; var command = new UnvoidRequirementTypeCommand(_requirementTypeId, 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 requirementTypeId = 1; var reqTypeRepositoryMock = new Mock <IRequirementTypeRepository>(); _requirementType = new RequirementType(TestPlant, "TestCode", "RequirementTypeTitle", RequirementTypeIcon.Other, 10); _requirementType.IsVoided = true; reqTypeRepositoryMock .Setup(r => r.GetByIdAsync(requirementTypeId)) .Returns(Task.FromResult(_requirementType)); _command = new UnvoidRequirementTypeCommand(requirementTypeId, _rowVersion); _dut = new UnvoidRequirementTypeCommandHandler( reqTypeRepositoryMock.Object, UnitOfWorkMock.Object); }