private string CreateCsvLine(CrmEntityStore record, List <string> header)
        {
            if (record != null)
            {
                string[] items = new string[header.Count];
                items[0] = record.Id.ToString();
                foreach (var item in record.Attributes)
                {
                    int position = header.IndexOf(item.AttributeName);

                    if (position >= 0)
                    {
                        object attrValue = EntityConverterHelper.GetAttributeValueForCsv(item);
                        if (item.AttributeType == "System.String")
                        {
                            string atVal = attrValue?.ToString().Replace("\"", "\"\"");
                            items[position] = $"\"{atVal}\"";
                        }
                        else
                        {
                            items[position] = attrValue?.ToString();
                        }
                    }
                }

                return(string.Join(delimiter, items));
            }

            return(null);
        }
        public void CrmEntityStoreNullEntityWrapper()
        {
            EntityWrapper entity = null;

            FluentActions.Invoking(() => systemUnderTest = new CrmEntityStore(entity))
            .Should()
            .Throw <ArgumentNullException>();
        }
        public void CrmEntityStoreTest()
        {
            FluentActions.Invoking(() => systemUnderTest = new CrmEntityStore())
            .Should()
            .NotThrow();

            Assert.IsTrue(systemUnderTest.Attributes.Count == 0);
        }
        public void CrmEntityStoreEntity()
        {
            var entity = new Entity("test", Guid.NewGuid());

            FluentActions.Invoking(() => systemUnderTest = new CrmEntityStore(entity))
            .Should()
            .NotThrow();

            Assert.IsTrue(systemUnderTest.Attributes.Count == 0);
            Assert.AreEqual(entity.Id, systemUnderTest.Id);
            Assert.AreEqual(entity.LogicalName, systemUnderTest.LogicalName);
            Assert.AreEqual(entity.Attributes.Count, systemUnderTest.Attributes.Count);
        }