Inheritance: IMixin
Exemplo n.º 1
0
 public void PropertyNameIsTrimmed()
 {
     var banana = new Product();
     banana.SetProperty("  My property     ", "test");
     Assert.AreEqual("test", banana.GetProperty(" My property "));
     Assert.AreEqual(banana.GetProperty("     My property  "), banana.GetProperty("My property"));
 }
Exemplo n.º 2
0
        public void BasicFeatures()
        {
            var banana = new Product
            {
                Name = "Banana",
                Price = new decimal(2.5)
            };

            var members = banana.GetMembers();
            foreach (var member in members)
            {
                var value = banana.GetProperty(member);
                var type = banana.GetPropertyType(member);
                Console.WriteLine("{0} = {1} of type {2}", member, value, type);
            }

            var banana2 = new Product
            {
                Name = "Banana",
                Price = new decimal(2.5)
            };

            Assert.IsTrue(banana.EqualsByValue(banana2));
        }
Exemplo n.º 3
0
        public void Mapper()
        {
            var bananaDto = new ProductDto
            {
                Name = "Banana",
                Price = new decimal(2.5),
                ProducedBy = "Banana tree"
            };

            var banana = new Product();

            bananaDto.MapTo(banana);

            Assert.AreEqual(bananaDto.Name, banana.Name);
            Assert.AreEqual(bananaDto.Price, banana.Price);
        }
Exemplo n.º 4
0
 public void PropertyNameCannotStartWithHash()
 {
     var banana = new Product();
     Assert.Throws<Exception>(() => banana.SetProperty("#don't do it", "never"));
 }
Exemplo n.º 5
0
 public void CanSetArbitratyProperty()
 {
     var banana = new Product();
     banana.SetProperty("The place where it grows", "Africa");
     Assert.AreEqual("Africa", banana.GetProperty("The place where it grows"));
 }