예제 #1
0
        public void MissingProperty()
        {
            // Arrange
            var appSettings = new NameValueCollection(ConfigurationManager.AppSettings);
            appSettings.Add("Extra property", "whatever");

            // Act
            var actual = appSettings.ToObject<FlatData>();
        }
예제 #2
0
        public void MissingPropertySafe()
        {
            // Arrange
            var appSettings = new NameValueCollection(ConfigurationManager.AppSettings);
            appSettings.Add("Extra property", "whatever");

            var expected = new FlatData
            {
                Id = new Guid("366f4bd3-6717-4b14-9c79-70515296df7e"),
                Date = new DateTime(1999, 1, 1),
                Enum = Enumeration.Two,
                Text = "level 1",
            };

            // Act
            var actual = appSettings.ToObject<FlatData>();

            // Assert
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.Date, actual.Date);
            Assert.AreEqual(expected.Enum, actual.Enum);
            Assert.AreEqual(expected.Text, actual.Text);
        }
예제 #3
0
        public void MissingValue()
        {
            // Arrange
            var appSettings = new NameValueCollection(ConfigurationManager.AppSettings);
            appSettings.Remove("Text");

            // Act
            var actual = appSettings.ToObject<FlatData>();
        }
예제 #4
0
        public void Single()
        {
            // Arrange
            var expected = new SingleData { Id = new Guid("366f4bd3-6717-4b14-9c79-70515296df7e") };
            var appSettings = new NameValueCollection(ConfigurationManager.AppSettings);
            appSettings.Remove("Date");
            appSettings.Remove("Enum");
            appSettings.Remove("Text");
            appSettings.Remove("Array");

            // Act
            var actual = appSettings.ToObject<SingleData>();

            // Assert
            Assert.AreEqual(expected.Id, actual.Id);
        }