예제 #1
0
        public void GetValue_Returns_SetValue()
        {
            // Arrange
            ETag etag = new ETag();

            // Act & Assert
            etag["Name"] = "Name1";
            Assert.Equal("Name1", etag["Name"]);
        }
예제 #2
0
        public void DynamicGetValue_Returns_DynamicSetValue()
        {
            // Arrange
            dynamic etag = new ETag();

            // Act & Assert
            etag.Name = "Name1";
            Assert.Equal("Name1", etag.Name);
        }
예제 #3
0
        public void GetValue_ThrowsInvalidOperation_IfNotWellFormed()
        {
            // Arrange
            ETag etag = new ETag();
            etag["Name"] = "Name1";
            etag.IsWellFormed = false;

            // Act & Assert
            Assert.Throws<InvalidOperationException>(() => etag["Name"], "The ETag is not well-formed.");
        }
        public void ApplyTo_NewQueryReturned_GivenQueryable_SingleProperty()
        {
            // Arrange
            ETag<Customer> etagCustomer = new ETag<Customer>();
            dynamic etag = etagCustomer;
            etag.FirstName = "TestFName";

            // Act
            IQueryable queryable = etagCustomer.ApplyTo(_customers.AsQueryable());

            // Assert
            Assert.NotNull(queryable);
            IEnumerable<Customer> actualCustomers = Assert.IsAssignableFrom<IEnumerable<Customer>>(queryable);
            Assert.Equal(new[] { 1 }, actualCustomers.Select(customer => customer.ID));
        }
예제 #5
0
        public void ApplyTo_NewQueryReturned_GivenQueryable()
        {
            // Arrange
            ETag etagCustomer = new ETag { EntityType = typeof(Customer) };
            dynamic etag = etagCustomer;
            etag.FirstName = "Foo";

            // Act
            IQueryable queryable = etagCustomer.ApplyTo(_customers.AsQueryable());

            // Assert
            Assert.NotNull(queryable);
            IEnumerable<Customer> actualCustomers = Assert.IsAssignableFrom<IEnumerable<Customer>>(queryable);
            Assert.Equal(
                new[] { 1 },
                actualCustomers.Select(customer => customer.ID));
        }
예제 #6
0
        public void ApplyTo_NewQueryReturned_GivenQueryable_SingleProperty()
        {
            // Arrange
            ETag <Customer> etagCustomer = new ETag <Customer>();
            dynamic         etag         = etagCustomer;

            etag.FirstName = "TestFName";

            // Act
            IQueryable queryable = etagCustomer.ApplyTo(_customers.AsQueryable());

            // Assert
            Assert.NotNull(queryable);
            IEnumerable <Customer> actualCustomers = Assert.IsAssignableFrom <IEnumerable <Customer> >(queryable);

            Assert.Equal(new[] { 1 }, actualCustomers.Select(customer => customer.ID));
        }
예제 #7
0
        public void ApplyTo_NewQueryReturned_GivenQueryable_NoMatch()
        {
            // Arrange
            ETag etagCustomer = new ETag {
                EntityType = typeof(Customer)
            };
            dynamic etag = etagCustomer;

            etag.FirstName = "foo";

            // Act
            IQueryable queryable = etagCustomer.ApplyTo(_customers.AsQueryable());

            // Assert
            Assert.NotNull(queryable);
            IEnumerable <Customer> actualCustomers = Assert.IsAssignableFrom <IEnumerable <Customer> >(queryable);

            Assert.Equal(new int[0], actualCustomers.Select(customer => customer.ID));
        }
예제 #8
0
        public void ApplyTo_NewQueryReturned_GivenQueryable_MutipleProperties()
        {
            // Arrange
            ETag etagCustomer = new ETag {
                EntityType = typeof(Customer)
            };
            dynamic etag = etagCustomer;

            etag.FirstName = "Abc";
            etag.LastName  = "Xyz";

            // Act
            IQueryable queryable = etagCustomer.ApplyTo(_customers.AsQueryable());

            // Assert
            Assert.NotNull(queryable);
            IEnumerable <Customer> actualCustomers = Assert.IsAssignableFrom <IEnumerable <Customer> >(queryable);

            Assert.Equal(
                new[] { 2 },
                actualCustomers.Select(customer => customer.ID));
        }