Ejemplo n.º 1
0
        public void GivenAuthenticatedProviderWithSomeMailsInInboxWhenShowMailsMethodIsCalledThenControllerReturnsViewWithRequestedMessages(int page, int pageSize)
        {
            AddProviderParamsToCurrentUser();
            var mailList = new List <Mail>();

            for (int pageId = 0; pageId < page * 2; pageId++)
            {
                for (int entryId = 0; entryId < pageSize; entryId++)
                {
                    var mailId = new MailKit.UniqueId(Convert.ToUInt32(pageId) * Convert.ToUInt32(pageSize) + Convert.ToUInt32(entryId) + 1);
                    mailList.Add(new Mail()
                    {
                        ID   = mailId,
                        Date = DateTime.Now.AddMinutes(mailId.Id)
                    });
                }
            }


            mockProvider.Setup(mock => mock.GetMailsFromFolder(It.Is <string>(folder => folder.Equals("inbox")),
                                                               It.IsAny <int>(), It.IsAny <int>(), It.Is <string>(sortOder => sortOder.Equals("dateDesc"))))
            .Returns(new Tuple <IList <Mail>, HttpStatusCode>(mailList, HttpStatusCode.OK));
            var mockMailFolder = new Mock <IMailFolder>();

            mockMailFolder.Setup(mock => mock.Count).Returns(pageSize);
            mockProvider.Setup(mock => mock.GetFolder(It.Is <string>(name => name.Equals("inbox")))).Returns(mockMailFolder.Object);


            SetProviderConnectionResponse(HttpStatusCode.OK);
            SetProviderAuthenticationState(true);

            var viewResult = controller.ShowMails(page, pageSize, "inbox", "dateAsc", null, null).Result as PartialViewResult;

            Assert.AreEqual("_ShowMails", viewResult.ViewName);
            Assert.IsNull(viewResult.TempData["ErrorMessage"]);

            Assert.IsInstanceOfType(viewResult.Model, typeof(IPagedList <MailHeader>));
            var receivedModel = (IPagedList <MailHeader>)viewResult.Model;

            Assert.IsNotNull(receivedModel);
            var receivedMails = (IList <MailHeader>)(receivedModel.ToList());

            Assert.AreEqual(pageSize, receivedMails.Count);
            for (int entryId = 1; entryId < pageSize; entryId++)
            {
                Assert.AreEqual(Convert.ToUInt32(page - 1) * Convert.ToUInt32(pageSize) + Convert.ToUInt32(entryId) + 1, receivedMails.ElementAt(entryId).ID);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MailKit.MessageLabelsChangedEventArgs"/> class.
 /// </summary>
 /// <remarks>
 /// Creates a new <see cref="MessageLabelsChangedEventArgs"/>.
 /// </remarks>
 /// <param name="index">The message index.</param>
 /// <param name="uid">The unique id of the message.</param>
 /// <param name="labels">The message labels.</param>
 public MessageLabelsChangedEventArgs(int index, UniqueId uid, IList <string> labels) : base(index)
 {
     UniqueId = uid;
     Labels   = new ReadOnlyCollection <string> (labels);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MailKit.MessageFlagsChangedEventArgs"/> class.
 /// </summary>
 /// <remarks>
 /// Creates a new <see cref="MessageFlagsChangedEventArgs"/>.
 /// </remarks>
 /// <param name="index">The message index.</param>
 /// <param name="uid">The unique id of the message.</param>
 /// <param name="flags">The message flags.</param>
 /// <exception cref="System.ArgumentOutOfRangeException">
 /// <paramref name="index"/> is out of range.
 /// </exception>
 public MessageFlagsChangedEventArgs(int index, UniqueId uid, MessageFlags flags) : base(index)
 {
     Keywords = new HashSet <string> (StringComparer.OrdinalIgnoreCase);
     UniqueId = uid;
     Flags    = flags;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MailKit.MessageFlagsChangedEventArgs"/> class.
 /// </summary>
 /// <remarks>
 /// Creates a new <see cref="MessageFlagsChangedEventArgs"/>.
 /// </remarks>
 /// <param name="index">The message index.</param>
 /// <param name="uid">The unique id of the message.</param>
 /// <param name="flags">The message flags.</param>
 /// <exception cref="System.ArgumentOutOfRangeException">
 /// <paramref name="index"/> is out of range.
 /// </exception>
 public MessageFlagsChangedEventArgs(int index, UniqueId uid, MessageFlags flags) : base(index)
 {
     UserFlags = new HashSet <string> ();
     UniqueId  = uid;
     Flags     = flags;
 }