Beispiel #1
0
        public void ConvertThrowExceptionForNotSupportedDataTypeTest()
        {
            // Arrange
            var properties = new List <DataRecordLogProperty <int> >
            {
                new DataRecordLogProperty <int>
                {
                    Action             = DataRecordAction.Insert,
                    DataRecordId       = 1,
                    DataRecordParentId = 11,
                    PropertyName       = nameof(Alpha.Epsilon),
                    DataRecordName     = nameof(Alpha),
                    DataType           = typeof(AdditionalInformation),
                    LogEntryGroupId    = 888,
                    UserId             = 999,
                    Value = new AdditionalInformation {
                        Message = "MegaVolt"
                    },
                    Timestamp = DateTime.Today
                }
            };

            var settings = new DataRecordLogSettings
            {
                EnumAsString = true,
                UnsupportedDataTypeAction = UnsupportedDataTypeAction.ThrowExeception
            };

            var classUnderTest = new DataRecordLogEngine(settings);

            // Act
            classUnderTest.Convert(properties);
        }
Beispiel #2
0
        public void Setup()
        {
            var settings = new DataRecordLogSettings
            {
                EnumAsString = false,
                UnsupportedDataTypeAction = UnsupportedDataTypeAction.Ignore
            };

            _classUnderTest = new DataRecordLogEngine(settings);
        }
Beispiel #3
0
        public void ConvertTreadEnumAsStringTest()
        {
            // Arrange
            var properties = new List <DataRecordLogProperty <int> >
            {
                new DataRecordLogProperty <int>
                {
                    Action             = DataRecordAction.Insert,
                    DataRecordId       = 1,
                    DataRecordParentId = 11,
                    PropertyName       = nameof(Alpha.Delta),
                    DataRecordName     = nameof(Alpha),
                    DataType           = typeof(LogLevel),
                    LogEntryGroupId    = 888,
                    UserId             = 999,
                    Value     = LogLevel.Error,
                    Timestamp = DateTime.Today
                }
            };

            var settings = new DataRecordLogSettings
            {
                EnumAsString = true,
                UnsupportedDataTypeAction = UnsupportedDataTypeAction.Ignore
            };

            var classUnderTest = new DataRecordLogEngine(settings);

            // Act
            var logs = classUnderTest.Convert(properties);

            // Assert
            logs.Should().HaveCount(1);
            var logForInsert = logs.First();

            logForInsert.Action.Should().Be(DataRecordAction.Insert);
            logForInsert.DataRecordId.Should().Be(1);
            logForInsert.DataRecordParentId.Should().Be(11);
            logForInsert.DataRecordName.Should().Be(nameof(Alpha));
            logForInsert.LogEntryGroupId.Should().Be(888);
            logForInsert.UserId.Should().Be(999);
            logForInsert.Timestamp.Should().Be(DateTime.Today);
            logForInsert.Properties[nameof(Alpha.Delta)].Value.Should().Be(LogLevel.Error.ToString());
            logForInsert.Properties[nameof(Alpha.Delta)].Type.Should().Be(FieldValueType.String);
        }