diff --git a/OptimizelySDK.Tests/EventTests/UserEventFactoryTest.cs b/OptimizelySDK.Tests/EventTests/UserEventFactoryTest.cs index ecf42fca..7edc2a5f 100644 --- a/OptimizelySDK.Tests/EventTests/UserEventFactoryTest.cs +++ b/OptimizelySDK.Tests/EventTests/UserEventFactoryTest.cs @@ -1,12 +1,12 @@ -/** +/* * - * Copyright 2019-2020, Optimizely and contributors + * Copyright 2019-2020, 2023 Optimizely and contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,6 +15,7 @@ * limitations under the License. */ +using System; using Moq; using NUnit.Framework; using OptimizelySDK.Config; @@ -96,6 +97,25 @@ public void ImpressionEventTestWithAttributes() TestData.CompareObjects(expectedVisitorAttributes, impressionEvent.VisitorAttributes); } + [Test] + public void EventFactoryBuildShouldLogInvalidUserAttributes() + { + var projectConfig = Config; + + var invalidUserAttributes = new UserAttributes + { + { "invalid_date_object", new DateTime() }, + { "invalid_array_use", new int[7] }, + }; + var expectedInvalidMessage = + $"User attributes: invalid_date_object, invalid_array_use were invalid and omitted."; + + EventFactory.BuildAttributeList(invalidUserAttributes, projectConfig, + LoggerMock.Object); + + LoggerMock.Verify(l => l.Log(LogLevel.WARN, expectedInvalidMessage), Times.Once()); + } + [Test] public void ConversionEventTest() {