public void GetValue_Returns_SetValue() { // Arrange ETag etag = new ETag(); // Act & Assert etag["Name"] = "Name1"; Assert.Equal("Name1", etag["Name"]); }
public void DynamicGetValue_Returns_DynamicSetValue() { // Arrange dynamic etag = new ETag(); // Act & Assert etag.Name = "Name1"; Assert.Equal("Name1", etag.Name); }
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)); }
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)); }
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)); }
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)); }
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)); }