private static void AssertNaNumberInCurrentValue(FieldDetailsDto f)
        {
            var numberValue = AssertIsNumberDto(f.CurrentValue);

            Assert.IsTrue(numberValue.IsNA);
            Assert.IsFalse(numberValue.Value.HasValue);
        }
        private void AssertAttachmentField(FieldDetailsDto f, FieldValueAttachment expectedValue)
        {
            Assert.AreEqual(FieldType.Attachment, f.FieldType);
            Assert.IsFalse(f.ShowPrevious);
            Assert.IsNull(f.Unit);

            Assert.IsInstanceOfType(f.CurrentValue, typeof(AttachmentDetailsDto));
            var attachmentDto = f.CurrentValue as AttachmentDetailsDto;

            Assert.IsNotNull(attachmentDto);
            Assert.AreEqual(expectedValue.Id, attachmentDto.Id);
            Assert.AreEqual(expectedValue.FileName, attachmentDto.FileName);
        }
        public void Constructor_ShouldSetProperties_ForNumberWithCurrentNotShowPrevious()
        {
            var field = new Field(_testPlant, "", FieldType.Number, 0, "mm", false);

            var dut = new FieldDetailsDto(
                field,
                new NumberValue(_testPlant, field, _number),
                new NumberValue(_testPlant, field, _number));

            Assert.IsFalse(dut.ShowPrevious);
            Assert.IsNotNull(dut.CurrentValue);
            Assert.IsNull(dut.PreviousValue);
            AssertNumberDto(dut.CurrentValue);
        }
        public void Constructor_ShouldSetProperties_ForCheckBox()
        {
            var field = new Field(_testPlant, "", FieldType.CheckBox, 0);

            var dut = new FieldDetailsDto(
                field,
                new CheckBoxChecked(_testPlant, field),
                null);

            var dto = dut.CurrentValue as CheckBoxDetailsDto;

            Assert.IsNotNull(dto);
            Assert.IsTrue(dto.IsChecked);
        }
        public void Constructor_ShouldSetProperties_ForNumberWithoutCurrent()
        {
            var fieldMock = new Mock <Field>(_testPlant, "Label", FieldType.Number, 0, "mm", true);

            fieldMock.SetupGet(f => f.Id).Returns(12);

            var dut = new FieldDetailsDto(fieldMock.Object, null, null);

            Assert.AreEqual(12, dut.Id);
            Assert.AreEqual(FieldType.Number, dut.FieldType);
            Assert.AreEqual("Label", dut.Label);
            Assert.AreEqual("mm", dut.Unit);
            Assert.IsTrue(dut.ShowPrevious);
            Assert.IsNull(dut.CurrentValue);
            Assert.IsNull(dut.PreviousValue);
        }
        public void Constructor_ShouldSetProperties_ForAttachment()
        {
            var field = new Field(_testPlant, "", FieldType.Attachment, 0);

            var fileName   = "FilA.txt";
            var attachment = new FieldValueAttachment(_testPlant, Guid.Empty, fileName);

            attachment.SetProtectedIdForTesting(11);

            var dut = new FieldDetailsDto(
                field,
                new AttachmentValue(_testPlant, field, attachment),
                null);

            var dto = dut.CurrentValue as AttachmentDetailsDto;

            Assert.IsNotNull(dto);
            Assert.AreEqual(11, dto.Id);
            Assert.AreEqual(fileName, dto.FileName);
        }
        private static void AssertNumberInPreviousValue(FieldDetailsDto f, double expectedValue)
        {
            var numberValue = AssertIsNumberDto(f.PreviousValue);

            AssertNumberDto(numberValue, expectedValue);
        }
 private void AssertNumberWithNoPreviewField(FieldDetailsDto f)
 {
     Assert.AreEqual(FieldType.Number, f.FieldType);
     Assert.IsFalse(f.ShowPrevious);
     Assert.AreEqual(_unit, f.Unit);
 }
 private void AssertCheckBoxField(FieldDetailsDto f)
 {
     Assert.AreEqual(FieldType.CheckBox, f.FieldType);
     Assert.IsFalse(f.ShowPrevious);
     Assert.IsNull(f.Unit);
 }