Exemple #1
0
        public void MatchComponentsTest()
        {
            string             field   = "Content-Type: Multipart/Mixed;boundary=\"Boundary-00=_T7P340MWKGMMYJ0CCJD0\"";
            ContentTypePattern pattern = new ContentTypePattern();
            Match match = pattern.RegularExpression.Match(field);

            Assert.That(match.Value, Iz.EqualTo("Content-Type: Multipart/Mixed;boundary=\"Boundary-00=_T7P340MWKGMMYJ0CCJD0\""));
        }
Exemple #2
0
        public void TestThatCorrectNumberOfImagesGetsParsed()
        {
            Assert.That(m_Stream, Iz.Not.Null);
            MIMER.IEndCriteriaStrategy endofmessage = new BasicEndOfMessageStrategy();
            var message = new MailReader().ReadMimeMessage(ref m_Stream, endofmessage);

            Assert.That(message.Attachments.Count(a => a.Type.Equals("image")), Iz.EqualTo(105));
        }
        public void CanRunAndReturnsUserResultNoMailSent()
        {
            var outParams = RunWorkflow(GetEmailSettings(), GetFilterSettings("EntryType = \"Error\" And EventID = 667"));

            Assert.That(outParams.UserResultMessage, Iz.EqualTo("No events. No mail has been sent from FRENDS Radon."));
            Assert.That(smtpServer.ReceivedEmailCount, Iz.LessThan(1));
            smtpServer.ClearReceivedEmail();
        }
        public void CanRunAndReturnsUserResultSuccess()
        {
            const string eventName = "RadonWFTestMessage CanRunAndReturnsUserResultSuccess";

            WriteToLogWithStandardLog(eventName, EventLogEntryType.Error, 666);
            var outParams = RunWorkflow(GetEmailSettings(), GetFilterSettings("EntryType = \"Error\" And EventID = 666"));

            Assert.That(outParams.UserResultMessage, Iz.EqualTo("Mail sent to [email protected]"));
            Assert.That(smtpServer.ReceivedEmailCount, Is.EqualTo(1));
            var body = SmtpSenderTest.ParseMessageBody(smtpServer.ReceivedEmail.Single().Body);

            Assert.That(body, Does.Contain(eventName));
            smtpServer.ClearReceivedEmail();
        }
        public void CanReadOtherThanApplicationLog()
        {
            const string eventName = "TestEvent CanReadOtherThanApplicationLog";

            WriteToLogWithCustomLog("TestLog", "TestLogSource", eventName, null);

            var outParams = RunWorkflow(GetEmailSettings(), GetFilterSettings("", "", "TestLog"));

            Assert.That(outParams.UserResultMessage, Iz.EqualTo("Mail sent to [email protected]"));
            Assert.That(smtpServer.ReceivedEmailCount, Is.EqualTo(1));

            var body = SmtpSenderTest.ParseMessageBody(smtpServer.ReceivedEmail.Single().Body);

            Assert.That(body, Does.Contain(eventName));
            smtpServer.ClearReceivedEmail();
        }
Exemple #6
0
        public void ThrowsOnTooLong()
        {
            PropertyValueException ex = Assert.Throws <PropertyValueException>(() =>
            {
                using (ISession s = OpenSession())
                {
                    StringClass b = new StringClass();
                    b.StringValue = "0123456789a";
                    s.Save(b);
                    s.Flush();
                }
            });

            Assert.That(ex.Message, Iz.EqualTo("Error dehydrating property value for NHibernate.Test.TypesTest.StringClass.StringValue"));
            Assert.That(ex.InnerException, Iz.TypeOf <HibernateException>());
            Assert.That(ex.InnerException.Message, Iz.EqualTo("The length of the string value exceeds the length configured in the mapping."));
        }
        public void CanReadRemoteEventLog()
        {
            const string eventName     = "TestEvent CanReadRemoteEventLog";
            var          remoteMachine = ConfigurationManager.AppSettings["RemoteMachineName"];

            WriteToLogWithCustomLog("Application", "testSource", eventName, remoteMachine);

            var outParams = RunWorkflow(GetEmailSettings(), GetFilterSettings("EntryType = \"Error\" And EventID = 666", remoteMachine, ""));

            Assert.That(outParams.UserResultMessage, Iz.EqualTo("Mail sent to [email protected]"));
            Assert.That(smtpServer.ReceivedEmailCount, Is.EqualTo(1));

            var body = SmtpSenderTest.ParseMessageBody(smtpServer.ReceivedEmail.Single().Body);

            Assert.That(body, Does.Contain(eventName));
            smtpServer.ClearReceivedEmail();
        }
        public void NhThrowsOnTooLong()
        {
            int maxStringLength       = 4000;
            PropertyValueException ex = Assert.Throws <PropertyValueException>(() =>
            {
                using (ISession s = OpenSession())
                {
                    StringClass b     = new StringClass();
                    b.LongStringValue = new string('x', maxStringLength + 1);
                    s.Save(b);
                    s.Flush();
                }
            });

            Assert.That(ex.Message, Iz.EqualTo("Error dehydrating property value for NHibernate.Test.TypesTest.StringClass.LongStringValue"));
            Assert.That(ex.InnerException, Iz.TypeOf <HibernateException>());
            Assert.That(ex.InnerException.Message, Iz.EqualTo("The length of the string value exceeds the length configured in the mapping/parameter."));
        }
Exemple #9
0
        public void TestThatXmlFilesGetsParsed()
        {
            Assert.That(m_Stream, Iz.Not.Null);
            MIMER.IEndCriteriaStrategy endofmessage = new BasicEndOfMessageStrategy();
            var message = new MailReader().ReadMimeMessage(ref m_Stream, endofmessage);

            Assert.That(message.Attachments.Count(a => a.Type.Equals("text") && a.SubType.Equals("xml")), Iz.EqualTo(1));
        }
Exemple #10
0
        public void TestParse()
        {
            Assert.IsNotNull(m_Stream);
            MIMER.RFC2045.MailReader   m            = new MailReader();
            MIMER.IEndCriteriaStrategy endofmessage = new BasicEndOfMessageStrategy();

            MIMER.RFC2045.IMimeMailMessage message = m.ReadMimeMessage(ref m_Stream, endofmessage);
            Assert.AreEqual("*****@*****.**", message.To[0].Address);
            Assert.AreEqual("*****@*****.**", message.CarbonCopy[0].Address);
            Assert.AreEqual("Testing the .eml format", message.Subject);
            Assert.AreEqual(3, message.Attachments.Count);
            Assert.That(message.Attachments.Count(x => x.Name != null && x.Name.Equals("cp_bg_black800.gif")), Iz.EqualTo(1));
            System.Net.Mail.MailMessage mailmessage = message.ToMailMessage();
            Assert.IsNull(mailmessage.From);
            Assert.AreEqual("*****@*****.**", mailmessage.CC[0].Address);
            Assert.AreEqual(message.TextMessage, mailmessage.Body);
            Assert.AreEqual(message.Attachments.Count, mailmessage.Attachments.Count);
        }
Exemple #11
0
        public void ThenTheValueShouldBe(string paramName, string value)
        {
            Mock <IParameterHelper> paramHelperMoq = (Mock <IParameterHelper>)ScenarioContext.Current["paramHelperMoq"];

            Assert.That(paramHelperMoq.Object.GetParameterValueAsString(paramName), Iz.EqualTo(value));
        }
Exemple #12
0
        public void triggersFrontMostObjectWhenObjectsOverlap()
        {
            var messagePromptCoordinator = new MessagePromptCoordinator(prompt.MockObject, messageBox.MockObject);

            var first = factory.CreateMock <GameObject>();

            first.Expects.Any.Method(_ => _.GetComponent <Sprite>()).WillReturn(sprite.MockObject);
            var second = factory.CreateMock <GameObject>();

            second.Expects.Any.Method(_ => _.GetComponent <Sprite>()).WillReturn(sprite.MockObject);

            var back          = new Vector3(0, 0, 0);
            var backTransform = new Transform()
            {
                position = back
            };
            var front          = new Vector3(0, 0, -1);
            var frontTransform = new Transform()
            {
                position = front
            };

            // if you think this looks weird, it is. we can't mock bareback public fields, and Unity is full of them.
            first.MockObject.transform  = backTransform;
            second.MockObject.transform = frontTransform;

            var frontObjectResponse = "front object response";
            var frontObjectAction   = "action2";
            var actionResponses     = new Dictionary <GameObject, ActionResponsePair[]> {
                { first.MockObject, new [] { new ActionResponsePair("action", new[] { "response" }) } },
                { second.MockObject, new [] { new ActionResponsePair(frontObjectAction, new[] { frontObjectResponse }) } }
            };

            using (factory.Ordered()) {
                expectTouchWithinSprite(sprite.MockObject, true);
                expectTouchWithinSprite(sprite.MockObject, false);
                expectTouchWithinSprite(sprite.MockObject, true);
            }

            messagePromptCoordinator.hintWhenTouched(
                GameObject => {
            },
                sensor.MockObject,
                beforeEverything,
                actionResponses
                );

            messagePromptCoordinator.Update(beforeEverything);

            GameObject triggeredObject = null;

            messageBox.Expects.One.Method(_ => _.setMessage("")).With(Is.EqualTo(frontObjectResponse));
            messageBox.Expects.One.Method(_ => _.hide());
            messageBox.Expects.One.Method(_ => _.show());

            prompt.Expects.One.Method(_ => _.setText("")).With(Is.EqualTo(frontObjectAction));
            prompt.Expects.One.Method(_ => _.hide());
            prompt.Expects.One.Method(_ => _.show());

            messagePromptCoordinator.hintWhenTouched(
                gameObject => {
                triggeredObject = gameObject;
            },
                sensor.MockObject,
                afterMessageTime,
                actionResponses
                );

            messageBox.Expects.One.Method(_ => _.hide());
            messagePromptCoordinator.Update(afterMessageTime + MessagePromptCoordinator.promptTime + 0.1f);

            Assert.That(triggeredObject, Iz.EqualTo(second.MockObject));
        }
Exemple #13
0
        public void TestReadAttachment()
        {
            IMimeMailMessage message = m_Reader.ReadMimeMessage(ref m_AttachmentStream, m_EndOfMessageStrategy);

            Assert.IsFalse(message.IsNull());
            Assert.AreEqual(3, message.Attachments.Count);
            Assert.AreEqual("*****@*****.**", message.From[0].Address);
            Assert.AreEqual("*****@*****.**", message.To[0].Address);
            StringAssert.Contains("Software engineering", message.TextMessage);
            Assert.That(message.Attachments.Count(x => x.Type != null && x.Type.Equals("application")), Iz.EqualTo(1));
            Assert.That(message.Attachments.Count(x => x.Name != null && x.Name.Equals("TDCOperatorGroup1.pdf")), Iz.EqualTo(1));
            Assert.That(message.Attachments.First(x => x.Name != null && x.Name.Equals("TDCOperatorGroup1.pdf")).Data.Length, Iz.GreaterThan(0));
        }
Exemple #14
0
        public void TestReadSMIMECertMessage()
        {
            Stream           smimeMessagaeStream = new MemoryStream(Encoding.ASCII.GetBytes(Strings.SMIME_CERT));
            IMimeMailMessage message             = m_Reader.ReadMimeMessage(ref smimeMessagaeStream, m_EndOfMessageStrategy);

            Assert.IsNotNull(message, "Message was null");
            Assert.AreEqual(3, message.Attachments.Count);
            Assert.That(message.Attachments.Count(x => x.Name != null && x.Name.Equals("smime.p7s")), Iz.EqualTo(1));
        }
Exemple #15
0
        public void TestReadEmbeddedWithAttachments()
        {
            IMimeMailMessage message =
                m_Reader.ReadMimeMessage(ref m_EmbeddedWithAttachmentsStream, m_EndOfMessageStrategy);

            Assert.AreEqual(4, message.Attachments.Count);
            Assert.AreEqual(1, message.Messages.Count);

            Assert.That(message.Attachments.Count(x => x.Name != null && x.Name.Equals("hostels.txt")), Iz.EqualTo(1));
            Assert.That(message.Attachments.Count(x => x.Name != null && x.Name.Equals("o_aspNet_Page_LifeCycle.jpg")), Iz.EqualTo(1));

            IMimeMailMessage firstMessage = message.Messages[0];

            Assert.AreEqual(5, firstMessage.Attachments.Count);
            Assert.AreEqual(1, firstMessage.Messages.Count);

            Assert.That(firstMessage.Attachments.Count(x => x.Name != null && x.Name.Equals("POP3ClientStates.vsd")), Iz.EqualTo(1));
            Assert.That(firstMessage.Attachments.Count(x => x.Name != null && x.Name.Equals("filmförslag.txt")), Iz.EqualTo(1));
            Assert.That(firstMessage.Attachments.Count(x => x.Name != null && x.Name.Equals("pleasewait.gif")), Iz.EqualTo(1));
            Assert.AreEqual("Test med flera olika", firstMessage.Subject);
            StringAssert.Contains("+46(0)123434534", firstMessage.TextMessage);

            IMimeMailMessage secondMessage = firstMessage.Messages[0];

            Assert.AreEqual(1, secondMessage.Messages.Count);

            Assert.AreEqual("VB: ", secondMessage.Subject);
            StringAssert.Contains("Teatar med embedded message", secondMessage.TextMessage);

            IMimeMailMessage thirdMessage = secondMessage.Messages[0];

            Assert.AreEqual("[CodeProject] Imbedded messages", thirdMessage.Subject);
            StringAssert.Contains("Great Article.", thirdMessage.TextMessage);
        }