Example #1
0
		public void Clone_ReturnsDifferentNonNullObject()
		{
			var r = new Role("code", "name", "def");
			var clone = r.Clone();
			Assert.IsNotNull(clone);
			Assert.AreNotSame(r, clone);
		}
Example #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));
		}
Example #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);
		}
Example #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));
		}
Example #5
0
		/// ------------------------------------------------------------------------------------
		/// <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));
		}
Example #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);
		}
Example #7
0
		public void Equals_CompareToNull_ReturnsFalse()
		{
			var r = new Role("codered", "Jaguar", "black");
			Assert.IsFalse(r.Equals(null));
		}
Example #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));
		}
Example #9
0
		public void Clone_ReturnsSameContent()
		{
			var r = new Role("code", "name", "def");
			Assert.IsTrue(r.AreContentsEqual(r.Clone()));
		}
Example #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;
		}
Example #11
0
		public void AreContentsEqual_OtherIsNull_ReturnsFalse()
		{
			var r = new Role(null, null, null);
			Assert.IsFalse(r.AreContentsEqual(null));
		}
Example #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));
		}
Example #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;
		}
Example #14
0
		/// ------------------------------------------------------------------------------------
		public Contribution(string name, Role role) : this()
		{
			ContributorName = name;
			Role = role;
		}
Example #15
0
		public void Equals_CompareToObjOfDifferentType_ReturnsFalse()
		{
			var r = new Role("codered", "Jaguar", "black");
			Assert.IsFalse(r.Equals("junk"));
		}
Example #16
0
		public void Equals_SameInstance_ReturnsTrue()
		{
			var r = new Role("codered", "Jaguar", "black");
			Assert.IsTrue(r.Equals(r));
		}
Example #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));
		}
Example #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));
		}
Example #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));
		}
Example #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));
		}