public void SuccessTest() { Order order = new Order(); order.Product = new Product("Ratched and Clank - Tools of Destruction", 61.05); order.Quantity = 4; Order expectedOrder = new Order(); expectedOrder.Product = new Product("Ratched and Clank - Tools of Destruction", 61.05); expectedOrder.Quantity = 4; AbstractConstraint sut = Property.AllPropertiesMatch(expectedOrder); Assert.True(sut.Eval(order)); }
public void DictionaryPropertyTest() { Catalog actual = new Catalog(); actual.Products.Add("RC01", new Product("Ratched and Clank - Tools of Destruction", 61.05)); actual.Products.Add("UDF1", new Product("Assassin's Creed", 69.99)); Catalog expected = new Catalog(); expected.Products.Add("RC01", new Product("Ratched and Clank - Tools of Destruction", 61.05)); expected.Products.Add("UDF1", new Product("Uncharted - Drake's Fortune", 69.99)); AbstractConstraint sut = Property.AllPropertiesMatch(expected); Assert.False(sut.Eval(actual)); Assert.Equal("Expected value of Catalog.Products[1].Value.Name is 'Uncharted - Drake's Fortune', actual value is 'Assassin's Creed'", sut.Message); }
public void CollectionExpectedCountTest() { List <Product> actual = new List <Product>(); actual.Add(new Product("Ratched and Clank - Tools of Destruction", 61.05)); actual.Add(new Product("Uncharted - Drake's Fortune", 69.99)); List <Product> expected = new List <Product>(); expected.Add(new Product("Ratched and Clank - Tools of Destruction", 61.05)); AbstractConstraint sut = Property.AllPropertiesMatch(expected); Assert.False(sut.Eval(actual)); Assert.Equal("expected number of items in collection List`1 is '1', actual is '2'", sut.Message); }
public void CollectionPropertyTest() { ShippingList actual = new ShippingList(); actual.Products.Add(new Product("Ratched and Clank - Tools of Destruction", 61.05)); actual.Products.Add(new Product("Assassin's Creed", 69.99)); ShippingList expected = new ShippingList(); expected.Products.Add(new Product("Ratched and Clank - Tools of Destruction", 61.05)); expected.Products.Add(new Product("Uncharted - Drake's Fortune", 69.99)); AbstractConstraint sut = Property.AllPropertiesMatch(expected); Assert.False(sut.Eval(actual)); Assert.Equal("Expected value of ShippingList.Products[1].Name is 'Uncharted - Drake's Fortune', actual value is 'Assassin's Creed'", sut.Message); }
public void ActualReferenceTypePropertyNullTest() { Order order = new Order(); order.Product = null; order.Quantity = 4; Order expectedOrder = new Order(); expectedOrder.Product = new Product("Ratched and Clank - Tools of Destruction", 61.05); expectedOrder.Quantity = 4; AbstractConstraint sut = Property.AllPropertiesMatch(expectedOrder); Assert.False(sut.Eval(order)); Assert.Equal("Expected value of Order.Product is 'Rhino.Mocks.Tests.AllPropertiesMatchConstraint.Product', actual value is null", sut.Message); }
public void NestedPropertyNotEqual() { Order order = new Order(); order.Product = new Product("Ratched and Clank - Tools of Destruction", 61.05); order.Quantity = 4; Order expectedOrder = new Order(); expectedOrder.Product = new Product("Ratched and Clank - Tools of Destruction", 50.0); expectedOrder.Quantity = 4; AbstractConstraint sut = Property.AllPropertiesMatch(expectedOrder); Assert.False(sut.Eval(order)); Assert.Equal("Expected value of Order.Product.Price is '50', actual value is '61.05'", sut.Message); }
public void NullableTypeSetTest() { Order order = new Order(); order.Product = new Product("Ratched and Clank - Tools of Destruction", 61.05); order.Quantity = 4; order.Product.Weight = 18; Order expectedOrder = new Order(); expectedOrder.Product = new Product("Ratched and Clank - Tools of Destruction", 61.05); expectedOrder.Quantity = 4; AbstractConstraint sut = Property.AllPropertiesMatch(expectedOrder); Assert.False(sut.Eval(order)); Assert.Equal("Expected value of Order.Product.Weight is null, actual value is '18'", sut.Message); }
public void DataRowTest() { DataTable table = new DataTable(); table.Columns.Add(new DataColumn("id", typeof(int))); table.Columns.Add(new DataColumn("name", typeof(string))); DataRow actual = table.NewRow(); actual["id"] = 1; actual["name"] = "Ratched and Clank - Tools of Destruction"; DataRow expected = table.NewRow(); expected["id"] = 2; expected["name"] = "Ratched and Clank - Tools of Destruction"; AbstractConstraint sut = Property.AllPropertiesMatch(expected); Assert.False(sut.Eval(actual)); Assert.Equal("Expected value of DataRow.ItemArray[0] is '2', actual value is '1'", sut.Message); }
/// <summary> /// Determines if the give object passes /// the constraint /// </summary> /// <param name="arg"></param> /// <returns></returns> public override bool Eval(object arg) { return(arg1.Eval(arg) && arg2.Eval(arg)); }