예제 #1
0
		public void Clone_ReturnsDifferentNonNullObject()
		{
			var r = new Role("code", "name", "def");
			var clone = r.Clone();
			Assert.IsNotNull(clone);
			Assert.AreNotSame(r, clone);
		}
예제 #2
0
		public void Clone_ReturnsSameContent()
		{
			var r = new Role("dev", "developer", "def");
			var c = new Contribution("name", r);
			c.Date = DateTime.Now;
			c.Comments = "stupid note";
			Assert.IsTrue(c.AreContentsEqual(c.Clone() as Contribution));
		}
예제 #3
0
		public void Clone_ReturnsDifferentNonNullObject()
		{
			var r = new Role("dev", "developer", "def");
			var c = new Contribution("name", r);
			var clone = c.Clone();
			Assert.IsNotNull(clone);
			Assert.AreNotSame(c, clone);
		}
예제 #4
0
		public void AreContentsEqual_RolesDifferent_ReturnsFalse()
		{
			var r1 = new Role("codered", null, null);
			var r2 = new Role("codeblue", null, null);

			var c1 = new Contribution("joey", r1);
			var c2 = new Contribution("joey", r2);
			Assert.IsFalse(c1.AreContentsEqual(c2));
		}
예제 #5
0
파일: Role.cs 프로젝트: jwickberg/libpalaso
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Returns true if the contents of this Role are the same as those of the specified
		/// Role.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public bool AreContentsEqual(Role other)
		{
			if (other == null)
				return false;

			// REVIEW: Do we really care if name and definition are different. Perhaps only
			// the code really matters.
			return (Code.Equals(other.Code) && Name.Equals(other.Name) &&
				Definition.Equals(other.Definition));
		}
예제 #6
0
		public void Clone_RolesAreDifferentObject()
		{
			var r = new Role("dev", "developer", "def");
			var c = new Contribution("name", r).Clone() as Contribution;
			Assert.AreNotSame(r, c.Role);
		}
예제 #7
0
		public void Equals_CompareToNull_ReturnsFalse()
		{
			var r = new Role("codered", "Jaguar", "black");
			Assert.IsFalse(r.Equals(null));
		}
예제 #8
0
		public void Equals_AllSame_ReturnsTrue()
		{
			var r1 = new Role("dev", "developer", "def");
			var r2 = new Role("dev", "developer", "def");

			var l1 = License.CreativeCommons_Attribution;
			var l2 = License.CreativeCommons_Attribution;

			var d1 = DateTime.Now;

			var c1 = new Contribution("joey", r1) { Date = d1, Comments = "get bread", ApprovedLicense = l1 };
			var c2 = new Contribution("joey", r2) { Date = d1, Comments = "get bread", ApprovedLicense = l2 };
			Assert.IsTrue(c1.Equals(c2));
		}
예제 #9
0
		public void Clone_ReturnsSameContent()
		{
			var r = new Role("code", "name", "def");
			Assert.IsTrue(r.AreContentsEqual(r.Clone()));
		}
예제 #10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Used to look up roles in the system's controlled vocabulary
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public bool TryGetRoleByName(string name, out Role role)
		{
			role = GetRoles().FirstOrDefault(r => r.Name == name);
			return role != null;
		}
예제 #11
0
		public void AreContentsEqual_OtherIsNull_ReturnsFalse()
		{
			var r = new Role(null, null, null);
			Assert.IsFalse(r.AreContentsEqual(null));
		}
예제 #12
0
		public void Equals_AllSame_ReturnsTrue()
		{
			var r1 = new Role("codered", "Jaguar", "black");
			var r2 = new Role("codered", "Jaguar", "black");
			Assert.IsTrue(r1.Equals(r2));
		}
예제 #13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Used to look up roles in the system's controlled vocabulary
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public bool TryGetRoleByCode(string code, out Role role)
		{
			role = GetRoles().FirstOrDefault(r => r.Code == code);
			return role != null;
		}
예제 #14
0
		/// ------------------------------------------------------------------------------------
		public Contribution(string name, Role role) : this()
		{
			ContributorName = name;
			Role = role;
		}
예제 #15
0
		public void Equals_CompareToObjOfDifferentType_ReturnsFalse()
		{
			var r = new Role("codered", "Jaguar", "black");
			Assert.IsFalse(r.Equals("junk"));
		}
예제 #16
0
		public void Equals_SameInstance_ReturnsTrue()
		{
			var r = new Role("codered", "Jaguar", "black");
			Assert.IsTrue(r.Equals(r));
		}
예제 #17
0
		public void AreContentsEqual_AllSame_ReturnsTrue()
		{
			var r1 = new Role("codered", "Jaguar", "black");
			var r2 = new Role("codered", "Jaguar", "black");
			Assert.IsTrue(r1.AreContentsEqual(r2));
		}
예제 #18
0
		public void AreContentsEqual_DifferentDefinitions_ReturnsFalse()
		{
			var r1 = new Role("codered", "Jaguar", "black");
			var r2 = new Role("codered", "Jaguar", "brown");
			Assert.IsFalse(r1.AreContentsEqual(r2));
		}
예제 #19
0
		public void AreContentsEqual_DifferentNames_ReturnsFalse()
		{
			var r1 = new Role("codered", "Jaguar", null);
			var r2 = new Role("codered", "Aston Martin", null);
			Assert.IsFalse(r1.AreContentsEqual(r2));
		}
예제 #20
0
		public void AreContentsEqual_DifferentCodes_ReturnsFalse()
		{
			var r1 = new Role("codered", null, null);
			var r2 = new Role("codeblue", null, null);
			Assert.IsFalse(r1.AreContentsEqual(r2));
		}