public void WithOnObjectWithNull()
		{
			var source = new { Property1 = new { Property2 = (object)null } };

			var result = source.With(s => s.Property1).With(s => s.Property2);

			Assert.AreEqual(null, result);
		}
		public void WithOnObjectWithValue()
		{
			var source = new { Property1 = new { Property2 = new { Property3 = "Some value" } } };

			var result = source.With(s => s.Property1).With(s => s.Property2).With(s => s.Property3);

			Assert.AreEqual("Some value", result);
		}
		public void WithNotEmpty()
		{
			var source = new[] { "a1", "a2,", "a3" };
			var result = source.With((string s) => s + "b").ToArray();

			Assert.AreEqual(source.Count(), result.Count());
			Assert.AreEqual(source[0] + "b", result[0]);
			Assert.AreEqual(source[1] + "b", result[1]);
			Assert.AreEqual(source[2] + "b", result[2]);
		}
Пример #4
0
		public void With_on_IEnumerable_returns_value()
		{
			var source = new[] { "a", "b", "c" };

			var result = source.With(c => c + c);

			Assert.AreEqual("aa,bb,cc", String.Join(",", result));
		}