public void ShouldSetDoubleProperty() { NameValueCollection collection = new NameValueCollection(); collection["DoubleValue"] = "12.34"; TestClass instance = collection.Create<TestClass>(); Assert.AreEqual(12.34, instance.DoubleValue, "The Double property was not set."); }
public void ShouldSetByteProperty() { NameValueCollection collection = new NameValueCollection(); collection["ByteValue"] = "123"; TestClass instance = collection.Create<TestClass>(); Assert.AreEqual(123, instance.ByteValue, "The Byte property was not set."); }
public void ShouldIgnoreNonGenericArrayProperty() { NameValueCollection collection = new NameValueCollection(); collection.Add("NonGenericArray", "Hello"); collection.Add("NonGenericArray", "World"); TestClass instance = collection.Create<TestClass>(); Assert.IsNull(instance.NonGenericArray, "The Array should have been ignored."); }
public void ShouldBuildUserEntity() { NameValueCollection collection = new NameValueCollection(); collection.Add("testuserid", "123"); collection.Add("username", "tparks"); collection.Add("birthday", "7-04-1933"); collection.Add("totalposts", null); collection.Add("posts", "This is my first post"); collection.Add("posts", "I really like toast"); TestUser instance = collection.Create<TestUser>(); Assert.AreEqual(123, instance.TestUserId, "The user ID was wrong."); Assert.AreEqual("tparks", instance.UserName, "The user name was wrong."); Assert.AreEqual(new DateTime(1933, 07, 04), instance.Birthday, "The birthday was wrong."); Assert.IsNull(instance.TotalPosts, "The total post should be null."); var expectedPosts = new string[] { "This is my first post", "I really like toast" }; CollectionAssert.AreEquivalent(expectedPosts, instance.Posts, "The posts were not set."); }
public void ShouldSetStringSetProperty() { NameValueCollection collection = new NameValueCollection(); collection.Add("StringSet", "Hello"); collection.Add("StringSet", "World"); TestClass instance = collection.Create<TestClass>(); HashSet<string> expected = new HashSet<string>() { "Hello", "World" }; Assert.IsTrue(expected.SetEquals(instance.StringSet), "The values were not set in a HashSet."); }
public void ShouldSetStringProperty() { NameValueCollection collection = new NameValueCollection(); collection["StringValue"] = "Test"; TestClass instance = collection.Create<TestClass>(); Assert.AreEqual("Test", instance.StringValue, "The String property was not set."); }
public void ShouldSetStringListProperty() { NameValueCollection collection = new NameValueCollection(); collection.Add("StringList", "Hello"); collection.Add("StringList", "World"); TestClass instance = collection.Create<TestClass>(); List<string> expected = new List<string>() { "Hello", "World" }; CollectionAssert.AreEqual(expected, instance.StringList, "The values were not set in a List<string>."); }
public void ShouldSetStringIListProperty() { NameValueCollection collection = new NameValueCollection(); collection.Add("StringIList", "Hello"); collection.Add("StringIList", "World"); TestClass instance = collection.Create<TestClass>(); string[] expected = new string[] { "Hello", "World" }; Assert.IsInstanceOfType(instance.StringIList, typeof(List<string>), "The collection should be a List<string>."); CollectionAssert.AreEqual(expected, (List<string>)instance.StringIList, "The values were not set in an IList."); }
public void ShouldSetStringArrayProperty() { NameValueCollection collection = new NameValueCollection(); collection.Add("StringArray", "Hello"); collection.Add("StringArray", "World"); TestClass instance = collection.Create<TestClass>(); string[] expected = new string[] { "Hello", "World" }; CollectionAssert.AreEqual(expected, instance.StringArray, "The values were not set in an string[]."); }
public void ShouldSetNullableInt64Property() { NameValueCollection collection = new NameValueCollection(); collection["NullableInt64Value"] = "123"; TestClass instance = collection.Create<TestClass>(); Assert.AreEqual(123, instance.NullableInt64Value, "The Int64 property was not set."); }
public void ShouldSetNullableInt32SetProperty() { NameValueCollection collection = new NameValueCollection(); collection.Add("NullableInt32Set", "123"); collection.Add("NullableInt32Set", "345"); TestClass instance = collection.Create<TestClass>(); HashSet<int?> expected = new HashSet<int?>() { 123, 345 }; Assert.IsTrue(expected.SetEquals(instance.NullableInt32Set), "The values were not set in a HashSet."); }
public void ShouldSetNullableInt32ListProperty() { NameValueCollection collection = new NameValueCollection(); collection.Add("NullableInt32List", "123"); collection.Add("NullableInt32List", "345"); TestClass instance = collection.Create<TestClass>(); List<int?> expected = new List<int?>() { 123, 345 }; CollectionAssert.AreEqual(expected, instance.NullableInt32List, "The values were not set in a List<int?>."); }
public void ShouldSetNullableInt32IListProperty() { NameValueCollection collection = new NameValueCollection(); collection.Add("NullableInt32IList", "123"); collection.Add("NullableInt32IList", "345"); TestClass instance = collection.Create<TestClass>(); int?[] expected = new int?[] { 123, 345 }; Assert.IsInstanceOfType(instance.NullableInt32IList, typeof(List<int?>), "The collection should be a List<int?>."); CollectionAssert.AreEqual(expected, (List<int?>)instance.NullableInt32IList, "The values were not set in an IList."); }
public void ShouldSetNullableInt32ArrayProperty() { NameValueCollection collection = new NameValueCollection(); collection.Add("NullableInt32Array", "123"); collection.Add("NullableInt32Array", "345"); TestClass instance = collection.Create<TestClass>(); int?[] expected = new int?[] { 123, 345 }; CollectionAssert.AreEqual(expected, instance.NullableInt32Array, "The values were not set in an int?[]."); }
public void ShouldSetNullableDecimalProperty() { NameValueCollection collection = new NameValueCollection(); collection["NullableDecimalValue"] = "12.34"; TestClass instance = collection.Create<TestClass>(); Assert.AreEqual(12.34m, instance.NullableDecimalValue, "The Decimal property was not set."); }
public void ShouldSetNonGenericEnumerableProperty() { NameValueCollection collection = new NameValueCollection(); collection.Add("NonGenericEnumerable", "Hello"); collection.Add("NonGenericEnumerable", "World"); TestClass instance = collection.Create<TestClass>(); List<string> expected = new List<string>() { "Hello", "World" }; Assert.IsInstanceOfType(instance.NonGenericEnumerable, typeof(List<string>), "The collection should be a List<string>."); CollectionAssert.AreEqual(expected, (List<string>)instance.NonGenericEnumerable, "The values were not set in an IEnumerable."); }