Esempio n. 1
0
        public void Accepts_EmptyArray()
        {
            // Arrange
            var products = new Product[0];
            var executor = new FirstResultFuncExecutor <Product>(products);

            // Act
            string name = executor.Execute(p => p.Name);

            // Assert
            Assert.Equal(null, name);
        }
Esempio n. 2
0
        public void Execute_ValidatesParameters()
        {
            // Arrange
            var products = new[]
            {
                new Product(), new Product()
            };
            var executor = new FirstResultFuncExecutor <Product>(products);

            // Act

            // Assert
            Assert.Throws <ArgumentNullException>(() => executor.Execute(null /* action */));
        }
Esempio n. 3
0
        public void Execute_ReturnsFirstItem()
        {
            // Arrange
            var products = new[]
            {
                new Product()
                {
                    Name = "Product A"
                },
                new Product()
                {
                    Name = "Product B"
                }
            };
            var executor = new FirstResultFuncExecutor <Product>(products);

            // Act
            string name = executor.Execute(p => p.Name);

            // Assert
            Assert.Equal("Product A", name);
        }
 /// <summary>
 /// Initialises a new instance of <see cref="ExtendedSqlServerTypeMapper"/>.
 /// </summary>
 /// <param name="hooks">The set of relational type mapper hooks.</param>
 public ExtendedSqlServerTypeMapper(IEnumerable <IRelationalTypeMapperHook> hooks)
 {
     _hooks = new FirstResultFuncExecutor <IRelationalTypeMapperHook>(Ensure.NotNull(hooks.ToArray(), nameof(hooks)));
 }
Esempio n. 5
0
 /// <summary>
 /// Initialises a new instance of <see cref="ExtendedEntityMaterializerSource"/>.
 /// </summary>
 /// <param name="hooks">The set of entity materializer source hooks.</param>
 public ExtendedEntityMaterializerSource(IEnumerable <IEntityMaterializerSourceHook> hooks)
     : base()
 {
     _executor = new FirstResultFuncExecutor <IEntityMaterializerSourceHook>(Ensure.NotNull(hooks, nameof(hooks)).ToArray());
 }