private void AppsListBuilder(IEnumerable<List<App>> result)
 {
     _asyncAppsResult = new List<App>();
     foreach (var userResult in result)
     {
         _asyncAppsResult.InsertRange(0, userResult);
     }
     Completion.Set();
 }
 private void CommentsListBuilder(List<List<Comment>> result)
 {
     _asyncCommentsResult = new List<Comment>();
     foreach (var userResult in result)
     {
         _asyncCommentsResult.InsertRange(0, userResult);
     }
     Completion.Set();
 }
		public void TestAddGetRemove ()
		{
			var foos = new List<string> (){ "1", "2", "3" };
			Assert.AreEqual (3, foos.Count);

			foos [2] = "MooFoey!";
			Assert.IsTrue (foos.Contains ("MooFoey!"));
			Assert.AreEqual ("MooFoey!", foos [2]);

			foos.Add ("Hello!");
			Assert.AreEqual (4, foos.Count);

			foos.Remove ("Hello!");
			Assert.AreEqual (3, foos.Count);

			foos.Insert (1, "foomoey!");
			Assert.AreEqual (4, foos.Count);

			foos.InsertRange (1, new List<string>{ "1", "2", "3" }); 
			Assert.AreEqual (7, foos.Count);

			foos.Clear ();
			Assert.IsEmpty (foos);
		}
Пример #4
0
        public void TestAddMessage()
        {
            Application app = SingletonProvider<TestSetup>.Instance.GetApp();
             Utilities utilities = app.Utilities;

             Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Create a new folder.
             IMAPFolder folder = account.IMAPFolders.get_ItemByName("INBOX");
             folder.Save();

             for (int i = 0; i < 3; i++)
             {
            hMailServer.Message message = folder.Messages.Add();
            message.set_Flag(eMessageFlag.eMFSeen, true);
            message.Save();

            POP3ClientSimulator.AssertMessageCount(account.Address, "test", ((i + 1)*2) - 1);

            SMTPClientSimulator.StaticSend("*****@*****.**", account.Address, "Test", "Test");
            POP3ClientSimulator.AssertMessageCount(account.Address, "test", (i + 1)*2);
             }

             POP3ClientSimulator.AssertMessageCount(account.Address, "test", 6);

             var sim = new IMAPClientSimulator();
             sim.ConnectAndLogon(account.Address, "test");
             sim.SelectFolder("Inbox");

             string response = sim.Fetch("1:6 UID");

             string[] lines = Strings.Split(response, Environment.NewLine, -1, CompareMethod.Text);

             var uids = new List<string>();

             foreach (string line in lines)
             {
            int paraPos = line.IndexOf("(");
            int paraEndPos = line.IndexOf(")");

            if (paraPos < 0 || paraEndPos < 0)
               continue;

            string paraContent = line.Substring(paraPos + 1, paraEndPos - paraPos - 1);

            if (!uids.Contains(paraContent))
               uids.Add(paraContent);
             }

             CustomAssert.AreEqual(6, uids.Count);

             // Make sure the UIDS are sorted properly by creating a copy, sort the copy
             // and then compare to original.
             var copy = new List<string>();
             copy.InsertRange(0, uids);
             copy.Sort();

             CustomAssert.AreEqual(copy, uids);
        }
Пример #5
0
 private string[] AddToStandardList(params string[] tags)
 {
     List<string> result = new List<string>(standardTags);
     result.InsertRange(0, tags);
     return result.ToArray();
 }
Пример #6
0
        private void ValidateSyntaxTree(NDjango.Interfaces.ITemplateManager manager)
        {
            ITemplate template = manager.GetTemplate(Template, new TestTyperesolver(),
                new NDjango.TypeResolver.ModelDescriptor(new NDjango.TypeResolver.IDjangoType[]
                    {
                        new NDjango.TypeResolver.CLRTypeDjangoType("Standard", typeof(EmptyClass))
                    }));

            //the same logic responsible for retriving nodes as in NodeProvider class (DjangoDesigner).
            List<INode> nodes = GetNodes(template.Nodes.ToList<INodeImpl>().ConvertAll
                (node => (INode)node)).FindAll(node =>
                    (node is ICompletionValuesProvider)
                    || (node.NodeType == NodeType.ParsingContext)
                    || (node.ErrorMessage.Message != ""));
            List<DesignerData> actualResult = nodes.ConvertAll(
                node =>
                {
                    var value_provider = node as ICompletionValuesProvider;
                    var values =
                        value_provider == null ?
                            new List<string>()
                            : value_provider.Values;
                    List<string> contextValues = new List<string>(values);
                    if (node.NodeType == NodeType.ParsingContext)
                    {
                        contextValues.InsertRange(0 ,(node.Context.TagClosures));
                        return new DesignerData(node.Position, node.Length, contextValues.ToArray(), node.ErrorMessage.Severity, node.ErrorMessage.Message);
                    }
                    else if (node.NodeType == NodeType.Reference)
                    {
                        return new DesignerData(node.Position, node.Length, GetModelValues(node.Context.Model, RecursionDepth).ToArray(), node.ErrorMessage.Severity, node.ErrorMessage.Message);
                    }
                    else
                        return new DesignerData(node.Position, node.Length, new List<string>(values).ToArray(), node.ErrorMessage.Severity, node.ErrorMessage.Message);
                });

            for (int i = 0; i < actualResult.Count; i++)
            {
                if (actualResult[i].Values.Length == 0)
                    continue;

                Assert.AreEqual(ResultForDesigner[i].Length, actualResult[i].Length, "Invalid Length");
                Assert.AreEqual(ResultForDesigner[i].Position, actualResult[i].Position, "Invalid Position");
                Assert.AreEqual(ResultForDesigner[i].Severity, actualResult[i].Severity, "Invalid Severity");
                Assert.AreEqual(ResultForDesigner[i].ErrorMessage, actualResult[i].ErrorMessage, "Invalid ErrorMessage");
                Assert.AreEqual(ResultForDesigner[i].Values, actualResult[i].Values, "Invalid Values Array " + i);
            }
        }
Пример #7
0
        public void Prepend_ToArray_QueryUsingCql()
        {
            Tuple<Table<EntityWithArrayType>, List<EntityWithArrayType>> tupleArrayType = EntityWithArrayType.SetupDefaultTable(_session);
            Table<EntityWithArrayType> table = tupleArrayType.Item1;
            List<EntityWithArrayType> expectedEntities = tupleArrayType.Item2;

            string[] arrToAdd = new string[] { "random_" + Randomm.RandomAlphaNum(10), "random_" + Randomm.RandomAlphaNum(10), "random_" + Randomm.RandomAlphaNum(10), };
            List<string> listReversed = arrToAdd.ToList();
            listReversed.Reverse();
            string[] arrReversed = listReversed.ToArray();

            EntityWithArrayType singleEntity = expectedEntities.First();
            EntityWithArrayType expectedEntity = singleEntity.Clone();
            List<string> strValsAsList = new List<string>();
            strValsAsList.AddRange(expectedEntity.ArrayType);
            strValsAsList.InsertRange(0, arrReversed);
            expectedEntity.ArrayType = strValsAsList.ToArray();

            // Append the values
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithArrayType { ArrayType = CqlOperator.Prepend(arrToAdd) }).Update().Execute();

            // Validate the final state of the data
            List<Row> rows = _session.Execute("SELECT * from " + table.Name + " where id='" + expectedEntity.Id + "'").GetRows().ToList();
            Assert.AreEqual(1, rows.Count);
            Assert.AreNotEqual(expectedEntity.ArrayType, singleEntity.ArrayType);
            string[] actualArr = rows[0].GetValue<string[]>("arraytype");
            CollectionAssert.AreEquivalent(expectedEntity.ArrayType, actualArr);
        }
Пример #8
0
        private void ValidateSyntaxTree(NDjango.Interfaces.ITemplateManager manager)
        {
            ITemplate template = manager.GetTemplate(Template);

            //the same logic responsible for retriving nodes as in NodeProvider class (DjangoDesigner).
            List<INode> nodes = GetNodes(template.Nodes.ToList<INodeImpl>().ConvertAll
                (node => (INode)node)).FindAll(node =>
                    (node.Values.ToList().Count != 0)
                    || (node.NodeType == NodeType.ParsingContext)
                    || (node.ErrorMessage.Message != ""));
            List<DesignerData> actualResult = nodes.ConvertAll(
                node =>
                {
                    List<string> contextValues = new List<string>(node.Values);
                    if (node.NodeType == NodeType.ParsingContext)
                    {
                        contextValues.InsertRange(0 ,((ParserNodes.ParsingContextNode)node).Context.TagClosures);
                        return new DesignerData(node.Position, node.Length, contextValues.ToArray(), node.ErrorMessage.Severity, node.ErrorMessage.Message);
                    }
                    else
                        return new DesignerData(node.Position, node.Length, new List<string>(node.Values).ToArray(), node.ErrorMessage.Severity, node.ErrorMessage.Message);
                });

            for (int i = 0; i < actualResult.Count; i++)
            {
                if (actualResult[i].Values.Length == 0)
                    continue;

                Assert.AreEqual(actualResult[i].Length, ResultForDesigner[i].Length, "Invalid Length");
                Assert.AreEqual(actualResult[i].Position, ResultForDesigner[i].Position, "Invalid Position");
                Assert.AreEqual(actualResult[i].Severity, ResultForDesigner[i].Severity, "Invalid Severity");
                Assert.AreEqual(actualResult[i].ErrorMessage, ResultForDesigner[i].ErrorMessage, "Invalid ErrorMessage");
                Assert.AreEqual(actualResult[i].Values, ResultForDesigner[i].Values, "Invalid Values");
            }
        }
Пример #9
0
        // causes System.ArgumentException : Delegate to an instance method cannot have null 'this'
        //[Test]
        //public void Test_PluginDialog()
        //{
        //    new PluginDialogTest().RunDialogTests();
        //}

        private string[] InsertPluginTabs(string[] tabs, params string[] plugintabs)
        {
            List<string> newtabs = new List<string>(tabs);
            newtabs.InsertRange(newtabs.Count - 1, plugintabs);
            return newtabs.ToArray();
        }
        private List<char> ShiftAlpha(string cipher)
        {
            var alpha = new List<char>(new char[26].Select((a, b) => (char)(b + 97)).ToArray());
            var startIndex = alpha.IndexOf(Convert.ToChar(cipher));

            var alphaNew = new char[alpha.Count];
            alpha.CopyTo(alphaNew);

            alpha.InsertRange(alpha.Count, alphaNew.Take(startIndex));
            return alpha.Skip(startIndex).ToList();
        }
 private void GroupsListBuilder(List<List<Group>> result)
 {
     _asyncGroupsResult = new List<Group>();
     foreach (var userResult in result)
     {
         _asyncGroupsResult.InsertRange(0, userResult);
     }
     Completion.Set();
 }
 private void TrackListBuilder(IEnumerable<List<Track>> result)
 {
     _asyncTracksResult = new List<Track>();
     foreach (var userResult in result)
     {
         _asyncTracksResult.InsertRange(0, userResult);
     }
     Completion.Set();
 }
 private void UserListBuilder(List<List<User>> result)
 {
     _asyncUsersResult = new List<User>();
     foreach (var userResult in result)
     {
         _asyncUsersResult.InsertRange(0, userResult);   
     }
     Completion.Set();
 }