public void DoesNotMatchWriteOnlyProperty() { var o = new ObjectWithProperties(); Matcher m = new PropertyMatcher("WriteOnlyProperty", new AlwaysMatcher(true, "anything")); Assert.IsFalse(m.Matches(o), "should not match o"); }
public void DoesNotMatchObjectIfItDoesNotHaveNamedProperty() { var o = new ObjectWithProperties(); Matcher m = new PropertyMatcher("OtherProperty", new AlwaysMatcher(true, "anything")); Assert.IsFalse(m.Matches(o), "should not match o"); }
public void DoesNotMatchObjectIfItDoesNotHaveNamedProperty() { ObjectWithProperties o = new ObjectWithProperties(); Matcher m = new PropertyMatcher("OtherProperty", new AlwaysMatcher(true, "anything")); Assert.IsFalse(m.Matches(o), "should not match o"); }
public void DoesNotMatchWriteOnlyProperty() { ObjectWithProperties o = new ObjectWithProperties(); Matcher m = new PropertyMatcher("WriteOnlyProperty", new AlwaysMatcher(true, "anything")); Assert.IsFalse(m.Matches(o), "should not match o"); }
public void ConstructFieldOrPropertySetterFixture() { var action = ReflectionExtensions.ConstructFieldOrPropertySetter <ObjectWithProperties, int>("Property4"); var obj = new ObjectWithProperties(); obj.Property4 = 5; action(obj, 2); obj.Property4.Should().Equal(2); }
public void DoesNotMatchObjectIfPropertyMatcherDoesNotMatch() { var o = new ObjectWithProperties(); object aValue = new NamedObject("aValue"); object otherValue = new NamedObject("otherValue"); o.A = aValue; Matcher m = new PropertyMatcher("A", new SameMatcher(otherValue)); Assert.IsFalse(m.Matches(o), "should not match o"); }
public void MatchesObjectWithNamedPropertyAndMatchingPropertyValue() { ObjectWithProperties o = new ObjectWithProperties(); object aValue = new NamedObject("aValue"); o.A = aValue; Matcher m = new PropertyMatcher("A", Is.EqualTo(aValue)); Assert.IsTrue(m.Matches(o), "should match o"); }
public void DoesNotMatchObjectIfPropertyMatcherDoesNotMatch() { ObjectWithProperties o = new ObjectWithProperties(); object aValue = new NamedObject("aValue"); object otherValue = new NamedObject("otherValue"); o.A = aValue; Matcher m = new PropertyMatcher("A", new EqualMatcher(otherValue)); Assert.IsFalse(m.Matches(o), "should not match o"); }
public void Then_the_object_must_be_instantiated_with_the_context_injected_values() { FluentApplicationContext.Register <ObjectWithProperties>(); FluentApplicationContext.Register( c => new ObjectWithConstructor(c.GetObject <ObjectWithProperties>())); IApplicationContext context = _applicationContextContainer.InitialiseContext(); ObjectWithConstructor objectWithConstructor = context.GetObject <ObjectWithConstructor>(); ObjectWithProperties childObject = context.GetObject <ObjectWithProperties>(); Assert.IsNotNull(objectWithConstructor); Assert.IsNotNull(objectWithConstructor.ObjectInferface); Assert.AreSame(childObject, objectWithConstructor.ObjectInferface); }
public void ToPropertyValuesDictionaryFixture() { var testObject = new ObjectWithProperties() { NotPrimitive = new NotPrimitiveClass() }; var dictionary = testObject.ToPropertyValuesDictionary(); ((int)dictionary["Property1"]).Should().Equal(1); ((string)dictionary["Property2"]).Should().Equal("string"); ((DateTime)dictionary["Property3"]).Should().Equal(DateTime.MaxValue); ((NotPrimitiveClass)dictionary["NotPrimitive"]).Should().Not.Be.Null(); dictionary = testObject.ToPropertyValuesDictionary(filter: descriptor => descriptor.PropertyType.IsPrimitive); dictionary.Should().Count.Exactly(1); dictionary.Should().Not.Contain.One(kv => kv.Key == "NotPrimitive"); }
public void Verify(SecurityAssertion securityAssertion) { if (securityAssertion == null && securityAssertion.Payload == null) { return; } ObjectWithProperties owp = securityAssertion.Payload as ObjectWithProperties; if (owp == null) { return; } if (owp.Properties != null && owp.Properties.ContainsKey("fail")) { throw new SecurityException("Access denied"); } }
public void ObjectWithPropertyMatches() { var a = new ObjectWithProperties { Number = 2, String = "string", SomeIntProperty = 2 }; var b = new ObjectWithProperties { Number = 2, String = "string" }; var result = _calculator.Diff(a, b); Assert.True(result.ValuesMatch); }
public void MatchesObjectWithNamedPropertyAndMatchingPropertyValue() { var o = new ObjectWithProperties(); object aValue = new NamedObject("aValue"); o.A = aValue; Matcher m = new PropertyMatcher("A", Is.Same(aValue)); Assert.IsTrue(m.Matches(o), "should match o"); }
public void CloningAnObjectShouldCloneItsProperties() { var obj = new ObjectWithProperties { SomeValue = 5, SomeString = "Hello", SomeDouble = 0.5 }; var clone = Cloner.DeepClone(obj); Assert.That(clone.SomeValue, Is.EqualTo(obj.SomeValue)); Assert.That(clone.SomeString, Is.EqualTo(obj.SomeString)); Assert.That(clone.SomeDouble, Is.EqualTo(obj.SomeDouble)); }
public ObjectWithGenericCollectionAsPropertyReturningArray() { SomeCollection = new ObjectWithProperties[] { new ObjectWithProperties { SomeValue = 5, SomeString = "Hello", SomeDouble = 0.5 }, new ObjectWithProperties { SomeValue = 6, SomeString = "World", SomeDouble = 1 }, }; }