Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using NSubstitute.Exceptions;
- using NUnit.Framework;
- namespace NSubstitute.Acceptance.Specs
- {
- public class PropertyBehaviour
- {
- public interface IFoo
- {
- string Name { get; set; }
- DateTime Now { get; }
- string WriteOnly { set; }
- string this[int i] { get; set; }
- string this[string a, string b] { get; set; }
- }
- protected object _ignored;
- /* -- addded the following tests to the original file -- */
- [Test]
- public void Properties_Return_Expected_Values()
- {
- var foo = Substitute.For<IFoo>();
- foo.Name = "This name";
- Assert.That(foo.Name, Is.EqualTo("This name"));
- var bar = Substitute.For<IFoo>();
- bar.Name.Returns("This name");
- Assert.That(bar.Name, Is.EqualTo("This name"));
- }
- [Test]
- public void Set_Property_To_Value_Of_Another_By_Assignment()
- {
- var foo = Substitute.For<IFoo>();
- foo.Name = "This name";
- var bar = Substitute.For<IFoo>();
- bar.Name = foo.Name;
- Assert.That(foo.Name, Is.EqualTo("This name"));
- Assert.That(bar.Name, Is.EqualTo("This name"));
- }
- [Test]
- public void Set_Property_To_Value_Of_Another_By_Return_Value()
- {
- var foo = Substitute.For<IFoo>();
- foo.Name.Returns("This name");
- var bar = Substitute.For<IFoo>();
- bar.Name.Returns(foo.Name);
- Assert.That(foo.Name, Is.EqualTo("This name"));
- Assert.That(bar.Name, Is.EqualTo("This name"));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement