コード例 #1
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));
		}
コード例 #2
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);
		}
コード例 #3
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));
		}
コード例 #4
0
		public void AreContentsEqual_LicensesDifferent_ReturnsFalse()
		{
			var l1 = License.CreativeCommons_Attribution;
			var l2 = License.CreativeCommons_Attribution_ShareAlike;

			var c1 = new Contribution("joey", null) { ApprovedLicense = l1 };
			var c2 = new Contribution("joey", null) { ApprovedLicense = l2 };
			Assert.IsFalse(c1.AreContentsEqual(c2));
		}
コード例 #5
0
ファイル: Contribution.cs プロジェクト: vkarthim/libpalaso
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Returns true if the contents of this Contribution are the same as those of the
        /// specified Contribution.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public bool AreContentsEqual(Contribution other)
        {
            if (other == null)
            {
                return(false);
            }

            bool rolesEqual = ((Role == null && other.Role == null) ||
                               (Role != null && Role.Equals(other.Role)));

            bool licensesEqual = ((ApprovedLicense == null && other.ApprovedLicense == null) ||
                                  (ApprovedLicense != null && ApprovedLicense.Equals(other.ApprovedLicense)));

            return(rolesEqual && licensesEqual &&
                   ContributorName == other.ContributorName &&
                   Date == other.Date && Comments == other.Comments);
        }
コード例 #6
0
		public void Equals_DateIsNull_DoesNotThrow()
		{
			var c1 = new Contribution("joey", null) { Comments = "note" };
			var c2 = new Contribution("joey", null) { Comments = "note" };
			Assert.IsTrue(c1.Equals(c2));
		}
コード例 #7
0
		public void AreContentsEqual_NamesDifferent_ReturnsFalse()
		{
			var c1 = new Contribution("joey", null);
			var c2 = new Contribution("bucky", null);
			Assert.IsFalse(c1.AreContentsEqual(c2));
		}
コード例 #8
0
ファイル: Contribution.cs プロジェクト: jwickberg/libpalaso
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Returns true if the contents of this Contribution are the same as those of the
		/// specified Contribution.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public bool AreContentsEqual(Contribution other)
		{
			if (other == null)
				return false;

			bool rolesEqual = ((Role == null && other.Role == null) ||
				(Role != null && Role.Equals(other.Role)));

			bool licensesEqual = ((ApprovedLicense == null && other.ApprovedLicense == null) ||
				(ApprovedLicense != null && ApprovedLicense.Equals(other.ApprovedLicense)));

			return (rolesEqual && licensesEqual &&
				ContributorName == other.ContributorName &&
				Date == other.Date && Comments == other.Comments);
		}
コード例 #9
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);
		}
コード例 #10
0
		public void AreContentsEqual_OtherIsNull_ReturnsFalse()
		{
			var c = new Contribution(null, null);
			Assert.IsFalse(c.AreContentsEqual(null));
		}
コード例 #11
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));
		}
コード例 #12
0
		/// ------------------------------------------------------------------------------------
		private string GetContributorsMetsPairs(Contribution contribution)
		{
			var roleCode = (contribution.Role != null &&
				Properties.Settings.Default.RampContributorRoles.Contains(contribution.Role.Code) ?
				contribution.Role.Code : string.Empty);

			return JSONUtils.MakeKeyValuePair(kDefaultKey, contribution.ContributorName) +
				kSeparator + JSONUtils.MakeKeyValuePair(kRole, roleCode);
		}
コード例 #13
0
		public void SetContributors_SetTwice_ThrowsInvalidOperationException()
		{
			var contributors = new ContributionCollection();
			OlacSystem olacSystem = new OlacSystem();
			Role role = olacSystem.GetRoleByCodeOrThrow("author");
			var contrib = new Contribution("Erkel", role);
			contributors.Add(contrib);
			_helper.SetContributors(contributors);
			Assert.Throws<InvalidOperationException>(() => _helper.SetContributors(contributors));
		}
コード例 #14
0
		public void AreContentsEqual_DatesDifferent_ReturnsFalse()
		{
			var c1 = new Contribution("bucky", null) { Date = DateTime.Now };
			var c2 = new Contribution("bucky", null) { Date = DateTime.Now.AddDays(1) };
			Assert.IsFalse(c1.AreContentsEqual(c2));
		}
コード例 #15
0
		public void Equals_CompareToObjOfDifferentType_ReturnsFalse()
		{
			var c = new Contribution("joey", null);
			Assert.IsFalse(c.Equals("junk"));
		}
コード例 #16
0
		public void Equals_CompareToNull_ReturnsFalse()
		{
			var c = new Contribution("joey", null);
			Assert.IsFalse(c.Equals(null));
		}
コード例 #17
0
		public void Equals_SameInstance_ReturnsTrue()
		{
			var c = new Contribution("joey", null);
			Assert.IsTrue(c.Equals(c));
		}
コード例 #18
0
		public void AreContentsEqual_NotesDifferent_ReturnsFalse()
		{
			var c1 = new Contribution("bucky", null) { Comments = "get bread" };
			var c2 = new Contribution("bucky", null) { Comments = "get pickles" };
			Assert.IsFalse(c1.AreContentsEqual(c2));
		}
コード例 #19
0
		public void Equals_NoteIsNull_DoesNotThrow()
		{
			var now = DateTime.UtcNow;
			var c1 = new Contribution("joey", null) { Date = now };
			var c2 = new Contribution("joey", null) { Date = now };
			Assert.IsTrue(c1.Equals(c2));
		}