public void FlexiCardBlockOptions_CanBePopulated(FlexiCardBlockOptions dummyInitialOptions,
                                                         FlexiCardBlockOptions dummyExpectedOptions,
                                                         string dummyJson)
        {
            // Act
            JsonConvert.PopulateObject(dummyJson, dummyInitialOptions);

            // Assert
            FlexiCardBlockOptions result         = dummyInitialOptions;
            FlexiCardBlockOptions expectedResult = dummyExpectedOptions;

            Assert.Equal(expectedResult.Url, result.Url);
            Assert.Equal(expectedResult.BackgroundIcon, result.BackgroundIcon);
            Assert.Equal(expectedResult.Attributes, result.Attributes);
        }
示例#2
0
        public void Clone_ShallowClonesDefaultCardOptions()
        {
            // Arrange
            const string dummyUrl                    = "dummyUrl";
            const string dummyBackgroundIcon         = "dummyBackgroundIcon";
            var          dummyAttributes             = new ReadOnlyDictionary <string, string>(new Dictionary <string, string>());
            var          dummyFlexiCardBlockOptions  = new FlexiCardBlockOptions(dummyUrl, dummyBackgroundIcon, dummyAttributes);
            var          dummyFlexiCardsBlockOptions = new FlexiCardsBlockOptions(defaultCardOptions: dummyFlexiCardBlockOptions);

            // Act
            var result = (FlexiCardsBlockOptions)dummyFlexiCardsBlockOptions.Clone();

            // Assert
            Assert.NotSame(dummyFlexiCardBlockOptions, result.DefaultCardOptions);
            Assert.Equal(dummyUrl, result.DefaultCardOptions.Url);
            Assert.Equal(dummyBackgroundIcon, result.DefaultCardOptions.BackgroundIcon);
            // This is fine since if attributes are specified in JSON, the entire collection is replaced -
            // i.e. we won't mess up the attributes collection of the original FlexiCardBlockOptions instance.
            Assert.Same(dummyAttributes, result.DefaultCardOptions.Attributes);
        }