[smuxi: 151/179] Engine: implement ImageMessagePartModel.Equals()
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi: 151/179] Engine: implement ImageMessagePartModel.Equals()
- Date: Sat, 4 Nov 2017 05:50:23 +0000 (UTC)
commit 22f94c5083e69373a4ed6591ab0ece61b2990616
Author: Mirco Bauer <meebey meebey net>
Date: Wed May 31 23:30:04 2017 +0800
Engine: implement ImageMessagePartModel.Equals()
src/Engine-Tests/MessageModelTests.cs | 9 ++++++
src/Engine/Messages/ImageMessagePartModel.cs | 35 ++++++++++++++++++++-----
2 files changed, 37 insertions(+), 7 deletions(-)
---
diff --git a/src/Engine-Tests/MessageModelTests.cs b/src/Engine-Tests/MessageModelTests.cs
index 96760c1..5cd5283 100644
--- a/src/Engine-Tests/MessageModelTests.cs
+++ b/src/Engine-Tests/MessageModelTests.cs
@@ -63,6 +63,15 @@ namespace Smuxi.Engine
var textPart = (TextMessagePartModel) msg.MessageParts[0];
textPart.ForegroundColor = TextColor.Grey;
Assert.IsFalse(msg.Equals(SimpleMessage));
+
+ var actualMsg = new MessageModel();
+ actualMsg.MessageParts.Add(new ImageMessagePartModel("filename", "text"));
+ var expectedMsg = new MessageModel();
+ expectedMsg.MessageParts.Add(new ImageMessagePartModel("filename", "text"));
+ Assert.IsTrue(expectedMsg.Equals(actualMsg));
+ var imagePart = (ImageMessagePartModel) actualMsg.MessageParts[0];
+ imagePart.AlternativeText = "foo";
+ Assert.IsFalse(expectedMsg.Equals(actualMsg));
}
[Test]
diff --git a/src/Engine/Messages/ImageMessagePartModel.cs b/src/Engine/Messages/ImageMessagePartModel.cs
index d6ea51a..dec9abc 100644
--- a/src/Engine/Messages/ImageMessagePartModel.cs
+++ b/src/Engine/Messages/ImageMessagePartModel.cs
@@ -1,13 +1,7 @@
/*
- * $Id: Config.cs 100 2005-08-07 14:54:22Z meebey $
- * $URL: svn+ssh://svn.qnetp.net/svn/smuxi/smuxi/trunk/src/Engine/Config.cs $
- * $Rev: 100 $
- * $Author: meebey $
- * $Date: 2005-08-07 16:54:22 +0200 (Sun, 07 Aug 2005) $
- *
* Smuxi - Smart MUltipleXed Irc
*
- * Copyright (c) 2005-2006 Mirco Bauer <meebey meebey net>
+ * Copyright (c) 2008, 2012, 2017 Mirco Bauer <meebey meebey net>
*
* Full GPL License: <http://www.gnu.org/licenses/gpl.txt>
*
@@ -113,5 +107,32 @@ namespace Smuxi.Engine
sw.Write( f_ImageFileName);
sw.Write( f_AlternativeText);
}
+
+ public override bool Equals(object obj)
+ {
+ if (!(obj is ImageMessagePartModel)) {
+ return false;
+ }
+
+ var textPart = (ImageMessagePartModel) obj;
+ return Equals(textPart);
+ }
+
+ public override bool Equals(MessagePartModel part)
+ {
+ var imagePart = part as ImageMessagePartModel;
+ if ((object) imagePart == null) {
+ return false;
+ }
+
+ if (f_ImageFileName != imagePart.ImageFileName) {
+ return false;
+ }
+ if (f_AlternativeText != imagePart.AlternativeText) {
+ return false;
+ }
+
+ return base.Equals(imagePart);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]