示例#1
0
        public void ToString_NotModified()
        {
            textProperty.IsModified = false;

            String actual   = new LoggableProperty(textProperty, "Original").ToString();
            String expected = $"{textProperty.Name}: \"Original\"";

            Assert.Equal(expected, actual);
        }
        public void ToString_NotModified()
        {
            textProperty.IsModified = false;

            String expected = String.Format("{0}: {1}", textProperty.Name, "\"Original\"");
            String actual   = new LoggableProperty(textProperty, "Original").ToString();

            Assert.Equal(expected, actual);
        }
        public void ToString_FormatsModifiedToIsoDateTimeFormat()
        {
            dateProperty.CurrentValue = new DateTime(2014, 6, 8, 14, 16, 19);
            dateProperty.IsModified   = true;

            String expected = String.Format("{0}: {1} => {2}", dateProperty.Name, "\"2010-04-03 18:33:17\"", "\"2014-06-08 14:16:19\"");
            String actual   = new LoggableProperty(dateProperty, new DateTime(2010, 4, 3, 18, 33, 17)).ToString();

            Assert.Equal(expected, actual);
        }
示例#4
0
        public void ToString_Modified_Date()
        {
            dateProperty.CurrentValue = new DateTime(2014, 6, 8, 14, 16, 19);
            dateProperty.IsModified   = true;

            String actual   = new LoggableProperty(dateProperty, new DateTime(2010, 4, 3, 18, 33, 17)).ToString();
            String expected = $"{dateProperty.Name}: \"2010-04-03 18:33:17\" => \"2014-06-08 14:16:19\"";

            Assert.Equal(expected, actual);
        }
        public void ToString_FormatsNotModifiedToIsoDateTimeFormat()
        {
            dateProperty.CurrentValue = new DateTime(2014, 6, 8, 14, 16, 19);
            dateProperty.IsModified   = false;

            String actual   = new LoggableProperty(dateProperty, new DateTime(2014, 6, 8, 14, 16, 19)).ToString();
            String expected = String.Format("{0}: {1}", dateProperty.Name, "\"2014-06-08 14:16:19\"");

            Assert.Equal(expected, actual);
        }
示例#6
0
        public void ToString_Modified_CurrentValueNull()
        {
            textProperty.CurrentValue = null;
            textProperty.IsModified   = true;

            String actual   = new LoggableProperty(textProperty, "Original").ToString();
            String expected = $"{textProperty.Name}: \"Original\" => null";

            Assert.Equal(expected, actual);
        }
示例#7
0
        public void ToString_Modified_OriginalValueNull()
        {
            textProperty.CurrentValue = "Current";
            textProperty.IsModified   = true;

            String actual   = new LoggableProperty(textProperty, null).ToString();
            String expected = $"{textProperty.Name}: null => \"Current\"";

            Assert.Equal(expected, actual);
        }
示例#8
0
        public void ToString_NotModified_Date()
        {
            dateProperty.CurrentValue = new DateTime(2014, 6, 8, 14, 16, 19);
            dateProperty.IsModified   = false;

            String actual   = new LoggableProperty(dateProperty, new DateTime(2014, 6, 8, 14, 16, 19)).ToString();
            String expected = $"{dateProperty.Name}: \"2014-06-08 14:16:19\"";

            Assert.Equal(expected, actual);
        }
示例#9
0
        public void ToString_NotModified_Json()
        {
            textProperty.CurrentValue = "Current\r\nValue";
            textProperty.IsModified   = false;

            String actual   = new LoggableProperty(textProperty, "Original\r\nValue").ToString();
            String expected = $"{textProperty.Name}: \"Original\\r\\nValue\"";

            Assert.Equal(expected, actual);
        }
示例#10
0
        public void ToString_Modified_Json()
        {
            textProperty.CurrentValue = "Current\r\nValue";
            textProperty.IsModified   = true;

            String expected = $"{textProperty.Name}: 157.45 => \"Current\\r\\nValue\"";
            String actual   = new LoggableProperty(textProperty, 157.45).ToString();

            Assert.Equal(expected, actual);
        }
        public void ToString_Modified_OriginalValueNull()
        {
            textProperty.CurrentValue = "Current";
            textProperty.IsModified   = true;

            String expected = String.Format("{0}: {1} => {2}", textProperty.Name, "null", "\"Current\"");
            String actual   = new LoggableProperty(textProperty, null).ToString();

            Assert.Equal(expected, actual);
        }
示例#12
0
        public void ToString_NotModified_OriginalValueNull()
        {
            textProperty.CurrentValue = "Current";
            textProperty.IsModified   = false;

            String expected = $"{textProperty.Metadata.Name}: null";
            String actual   = new LoggableProperty(textProperty, null).ToString();

            Assert.Equal(expected, actual);
        }
        public void ToString_Modified_Json()
        {
            textProperty.CurrentValue = "Current\r\nValue";
            textProperty.IsModified   = true;

            String expected = String.Format("{0}: {1} => {2}", textProperty.Name, "157.45", "\"Current\\r\\nValue\"");
            String actual   = new LoggableProperty(textProperty, 157.45).ToString();

            Assert.Equal(expected, actual);
        }
        public void ToString_FormatsNotModifiedToJson()
        {
            textProperty.CurrentValue = "Current\r\nValue";
            textProperty.IsModified   = false;

            String expected = String.Format("{0}: {1}", textProperty.Name, "\"Original\\r\\nValue\"");
            String actual   = new LoggableProperty(textProperty, "Original\r\nValue").ToString();

            Assert.Equal(expected, actual);
        }
        public void ToString_FormatsModifiedToIsoDateTimeFormat()
        {
            dateProperty.CurrentValue = DateTime.MaxValue;
            dateProperty.IsModified   = true;

            String expected = String.Format("{0}: {1} => {2}", dateProperty.Name, "{null}", DateTime.MaxValue.ToString("yyyy-MM-dd hh:mm:ss"));
            String actual   = new LoggableProperty(dateProperty, null).ToString();

            Assert.AreEqual(expected, actual);
        }
        public void ToString_FormatsModifiedWithCurrentValueNull()
        {
            textProperty.CurrentValue = null;
            textProperty.IsModified   = true;

            String expected = String.Format("{0}: {1} => {2}", textProperty.Name, "Original", "{null}");
            String actual   = new LoggableProperty(textProperty, "Original").ToString();

            Assert.AreEqual(expected, actual);
        }
        public void ToString_FormatsNotModifiedToIsoDateTimeFormat()
        {
            dateProperty.CurrentValue = DateTime.MinValue;
            dateProperty.IsModified   = false;

            String expected = String.Format("{0}: {1}", dateProperty.Name, DateTime.MinValue.ToString("yyyy-MM-dd hh:mm:ss"));
            String actual   = new LoggableProperty(dateProperty, DateTime.MinValue).ToString();

            Assert.AreEqual(expected, actual);
        }
        public void ToString_FormatsNotModifiedWithOriginalValueNull()
        {
            textProperty.CurrentValue = "Current";
            textProperty.IsModified   = false;

            String expected = String.Format("{0}: {1}", textProperty.Name, "{null}");
            String actual   = new LoggableProperty(textProperty, null).ToString();

            Assert.AreEqual(expected, actual);
        }
示例#19
0
        public void LoggableEntity_CreatesPropertiesForModifiedEntity()
        {
            String title = model.Title;

            entry.State = EntityState.Modified;
            entry.CurrentValues["Title"]  = "Role";
            entry.OriginalValues["Title"] = "Role";

            LoggableProperty expected = new LoggableProperty(entry.Property("Title"), title);
            LoggableProperty actual   = new LoggableEntity(entry).Properties.Single();

            Assert.Equal(expected.IsModified, actual.IsModified);
            Assert.Equal(expected.ToString(), actual.ToString());
        }
示例#20
0
        public void LoggableEntity_CreatesPropertiesForAttachedEntity()
        {
            context.Dispose();
            String title = model.Title;

            context = new TestingContext();
            context.Set <TestModel>().Attach(model);

            entry = context.Entry <BaseModel>(model);
            entry.OriginalValues["Title"] = "Role";
            entry.CurrentValues["Title"]  = "Role";
            entry.State = EntityState.Modified;

            LoggableProperty expected = new LoggableProperty(entry.Property("Title"), title);
            LoggableProperty actual   = new LoggableEntity(entry).Properties.Single();

            Assert.Equal(expected.IsModified, actual.IsModified);
            Assert.Equal(expected.ToString(), actual.ToString());
        }