Esempio n. 1
0
 public void EmptyContainsNoElements()
 {
     using (var empty = Linq.Empty <int>().GetEnumerator())
     {
         Assert.False(empty.MoveNext());
     }
 }
Esempio n. 2
0
        public static System.Collections.Generic.IEnumerable <System.Reflection.PropertyInfo> GetAllProperties(this System.Type type, System.Reflection.BindingFlags flags)
        {
            if (type == null)
            {
                return(Enumerable.Empty <System.Reflection.PropertyInfo>());
            }

            return(type.GetProperties(flags)); //.Union(ReflectionHelper.GetAllProperties(type.BaseType, flags)).Distinct();
        }
Esempio n. 3
0
        public void EmptyIsASingletonPerElementType()
        {
            Assert.Same(Linq.Empty <int>(), Linq.Empty <int>());
            Assert.Same(Linq.Empty <long>(), Linq.Empty <long>());
            Assert.Same(Linq.Empty <string>(), Linq.Empty <string>());
            Assert.Same(Linq.Empty <object>(), Linq.Empty <object>());

            Assert.NotSame(Linq.Empty <long>(), Linq.Empty <int>());
            Assert.NotSame(Linq.Empty <string>(), Linq.Empty <object>());
        }
        /// <summary>
        ///     Get Space information see <a href="https://docs.atlassian.com/confluence/REST/latest/#d3e164">here</a>
        /// </summary>
        /// <param name="confluenceClient">ISpaceDomain to bind the extension method to</param>
        /// <param name="spaceKey">the space key</param>
        /// <param name="cancellationToken">CancellationToken</param>
        /// <returns>Space</returns>
        public static async Task<Space> GetAsync(this ISpaceDomain confluenceClient, string spaceKey, CancellationToken cancellationToken = default)
        {
            confluenceClient.Behaviour.MakeCurrent();
            var spaceUri = confluenceClient.ConfluenceApiUri.AppendSegments("space", spaceKey);

            var expand = string.Join(",", ConfluenceClientConfig.ExpandGetSpace ?? Enumerable.Empty<string>());
            if (!string.IsNullOrEmpty(expand))
            {
                spaceUri = spaceUri.ExtendQuery("expand", expand);
            }

            var response = await spaceUri.GetAsAsync<HttpResponse<Space, Error>>(cancellationToken).ConfigureAwait(false);
            return response.HandleErrors();
        }
Esempio n. 5
0
        static int Main(string[] args)
        {
            Console.WriteLine($"TestRobot1 started! args: {string.Join(", ", args ?? Enumerable.Empty<string>())}");

            //var processNames = System.Diagnostics.Process.GetProcesses().OrderBy(p => p.ProcessName).Select(p => p.ProcessName);
            //foreach (var processName in processNames)
            //{
            //    Console.WriteLine(processName);
            //}

            Thread.Sleep(7000);
            //Console.ReadKey();

            return(1);
        }
        /// <summary>
        ///     Get Spaces with specific parameters, see <a href="https://docs.atlassian.com/confluence/REST/latest/#d3e164">here</a>
        /// </summary>
        /// <param name="confluenceClient">ISpaceDomain to bind the extension method to</param>
        /// <param name="spaceKeys">IEnumerable of string with space keys</param>
        /// <param name="type">string filter the list of spaces returned by type (global, personal)</param>
        /// <param name="status">string filter the list of spaces returned by status (current, archived)</param>
        /// <param name="label">string filter the list of spaces returned by label</param>
        /// <param name="favourite">bool filter the list of spaces returned by favourites</param>
        /// <param name="start">the start point of the collection to return</param>
        /// <param name="limit">The maximum number of spaces to return per page. System default is 25, override this with a value. Note, this may be restricted by fixed system limits.</param>
        /// <param name="cancellationToken">CancellationToken</param>
        /// <returns>List of Spaces</returns>
        public static async Task <IList <Space> > GetAllWithParametersAsync(this ISpaceDomain confluenceClient, IEnumerable <string> spaceKeys = null, string type = null, string status = null, string label = null, bool?favourite = null, int?start = null, int?limit = null, CancellationToken cancellationToken = default)
        {
            confluenceClient.Behaviour.MakeCurrent();
            var spacesUri = confluenceClient.ConfluenceApiUri.AppendSegments("space");

            foreach (var spaceKey in spaceKeys ?? Enumerable.Empty <string>())
            {
                spacesUri = spacesUri.ExtendQuery("spaceKey", spaceKey);
            }

            if (!string.IsNullOrEmpty(type))
            {
                spacesUri = spacesUri.ExtendQuery("type", type);
            }
            if (!string.IsNullOrEmpty(status))
            {
                spacesUri = spacesUri.ExtendQuery("status", status);
            }
            if (!string.IsNullOrEmpty(label))
            {
                spacesUri = spacesUri.ExtendQuery("label", label);
            }
            if (favourite.HasValue)
            {
                spacesUri = spacesUri.ExtendQuery("favourite", favourite);
            }
            var expand = string.Join(",", ConfluenceClientConfig.ExpandGetSpace ?? Enumerable.Empty <string>());

            if (!string.IsNullOrEmpty(expand))
            {
                spacesUri = spacesUri.ExtendQuery("expand", expand);
            }
            if (start.HasValue)
            {
                spacesUri = spacesUri.ExtendQuery("start", start.Value);
            }
            if (limit.HasValue)
            {
                spacesUri = spacesUri.ExtendQuery("limit", limit.Value);
            }

            var response = await spacesUri.GetAsAsync <HttpResponse <Result <Space>, Error> >(cancellationToken).ConfigureAwait(false);

            return(response.HandleErrors()?.Results);
        }
Esempio n. 7
0
 public void ExactlyWithEmptySequenceHasExactlyOneElement()
 {
     Assert.IsFalse(LinqEnumerable.Empty <int>().Exactly(1));
 }
Esempio n. 8
0
 public void ExactlyWithEmptySequenceHasExactlyZeroElements()
 {
     Assert.IsTrue(LinqEnumerable.Empty <int>().Exactly(0));
 }
        /// <summary>
        ///     Update the attachment information
        /// </summary>
        /// <param name="confluenceClient">IAttachmentDomain to bind the extension method to</param>
        /// <param name="attachment">Attachment</param>
        /// <param name="cancellationToken">CancellationToken</param>
        /// <returns>Attachment</returns>
        public static async Task <Content> UpdateAsync(this IAttachmentDomain confluenceClient, Content attachment, CancellationToken cancellationToken = default)
        {
            confluenceClient.Behaviour.MakeCurrent();

            var attachmentsUri = confluenceClient.ConfluenceApiUri.AppendSegments("content", attachment.Container.Id, "child", "attachment", attachment.Id);

            var expand = string.Join(",", ConfluenceClientConfig.ExpandGetAttachments ?? Enumerable.Empty <string>());

            if (!string.IsNullOrEmpty(expand))
            {
                attachmentsUri = attachmentsUri.ExtendQuery("expand", expand);
            }

            var response = await attachmentsUri.GetAsAsync <HttpResponse <Content, Error> >(cancellationToken).ConfigureAwait(false);

            return(response.HandleErrors());
        }
Esempio n. 10
0
        private void AnalyzeReadWrite()
        {
            IEnumerable <Symbol> readInside, writtenInside, readOutside, writtenOutside, captured, unsafeAddressTaken;

            if (Succeeded)
            {
                ReadWriteWalker.Analyze(context.Compilation, context.Member, context.BoundNode, context.FirstInRegion, context.LastInRegion, UnassignedVariableAddressOfSyntaxes,
                                        readInside: out readInside, writtenInside: out writtenInside,
                                        readOutside: out readOutside, writtenOutside: out writtenOutside,
                                        captured: out captured, unsafeAddressTaken: out unsafeAddressTaken);
            }
            else
            {
                readInside = writtenInside = readOutside = writtenOutside = captured = unsafeAddressTaken = Enumerable.Empty <Symbol>();
            }

            Interlocked.CompareExchange(ref this.readInside, readInside, null);
            Interlocked.CompareExchange(ref this.writtenInside, writtenInside, null);
            Interlocked.CompareExchange(ref this.readOutside, readOutside, null);
            Interlocked.CompareExchange(ref this.writtenOutside, writtenOutside, null);
            Interlocked.CompareExchange(ref this.captured, captured, null);
            Interlocked.CompareExchange(ref this.unsafeAddressTaken, unsafeAddressTaken, null);
        }
Esempio n. 11
0
 public void AtMostWithEmptySequenceHasAtMostOneElement()
 {
     Assert.IsTrue(LinqEnumerable.Empty <int>().AtMost(1));
 }
Esempio n. 12
0
 public void AtMostWithEmptySequenceHasAtMostZeroElements()
 {
     Assert.IsTrue(LinqEnumerable.Empty <int>().AtMost(0));
 }
Esempio n. 13
0
 public void ToDelimitedStringWithEmptySequence()
 {
     Assert.That(LinqEnumerable.Empty <int>().ToDelimitedString(), Is.Empty);
 }
Esempio n. 14
0
 public void AtLeastWithEmptySequenceHasAtLeastManyElements()
 {
     Assert.IsFalse(LinqEnumerable.Empty <int>().AtLeast(2));
 }
Esempio n. 15
0
        public void RemoveAllTest()
        {
            try
            {
                int[] removeAll = Enumerable.Range(0, 5).RemoveAll(-1).ToArray();
                Assert.Fail(string.Join(", ", removeAll.Select(int32 => int32.ToString())));
            }
            catch (ArgumentOutOfRangeException exception)
            {
                Assert.AreEqual("remove", exception.ParamName);
            }
            EnumerableAssert.AreSequentialEqual(new int[] { 1, 2, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(0));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 2, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(1));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(2));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 4 }, Enumerable.Range(0, 5).RemoveAll(3));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 3 }, Enumerable.Range(0, 5).RemoveAll(4));
            try
            {
                int[] removeAll = Enumerable.Range(0, 5).RemoveAll(5).ToArray();
                Assert.Fail(string.Join(", ", removeAll.Select(int32 => int32.ToString())));
            }
            catch (ArgumentOutOfRangeException exception)
            {
                Assert.AreEqual("remove", exception.ParamName);
            }
            try
            {
                int[] removeAll = Enumerable.Range(0, 5).RemoveAll(6).ToArray();
                Assert.Fail(string.Join(", ", removeAll.Select(int32 => int32.ToString())));
            }
            catch (ArgumentOutOfRangeException exception)
            {
                Assert.AreEqual("remove", exception.ParamName);
            }
            EnumerableAssert.AreSequentialEqual(Enumerable.Empty <int>(), Enumerable.Repeat(0, 5).RemoveAll(0));
            try
            {
                int[] removeAll = Enumerable.Repeat(0, 5).RemoveAll(1).ToArray();
                Assert.Fail(string.Join(", ", removeAll.Select(int32 => int32.ToString())));
            }
            catch (ArgumentOutOfRangeException exception)
            {
                Assert.AreEqual("remove", exception.ParamName);
            }
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 3, 0, 1, 2, 3 }, Enumerable.Range(0, 5).Concat(Enumerable.Range(0, 5)).RemoveAll(4));
            EnumerableAssert.AreSequentialEqual(new int[] { 1, 2, 3, 4, 1, 2, 3, 4 }, Enumerable.Range(0, 5).Concat(Enumerable.Range(0, 5)).RemoveAll(0));

            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(-1, null, ListQueryMode.Normalize));
            EnumerableAssert.AreSequentialEqual(new int[] { 1, 2, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(0, null, ListQueryMode.Normalize));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 2, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(1, null, ListQueryMode.Normalize));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(2, null, ListQueryMode.Normalize));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 4 }, Enumerable.Range(0, 5).RemoveAll(3, null, ListQueryMode.Normalize));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 3 }, Enumerable.Range(0, 5).RemoveAll(4, null, ListQueryMode.Normalize));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(5, null, ListQueryMode.Normalize));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(6, null, ListQueryMode.Normalize));
            EnumerableAssert.AreSequentialEqual(Enumerable.Empty <int>(), Enumerable.Repeat(0, 5).RemoveAll(0, null, ListQueryMode.Normalize));
            EnumerableAssert.AreSequentialEqual(Enumerable.Repeat(0, 5), Enumerable.Repeat(0, 5).RemoveAll(1, null, ListQueryMode.Normalize));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 3, 0, 1, 2, 3 }, Enumerable.Range(0, 5).Concat(Enumerable.Range(0, 5)).RemoveAll(4, null, ListQueryMode.Normalize));
            EnumerableAssert.AreSequentialEqual(new int[] { 1, 2, 3, 4, 1, 2, 3, 4 }, Enumerable.Range(0, 5).Concat(Enumerable.Range(0, 5)).RemoveAll(0, null, ListQueryMode.Normalize));

            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(-1, null, ListQueryMode.Ignore));
            EnumerableAssert.AreSequentialEqual(new int[] { 1, 2, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(0, null, ListQueryMode.Ignore));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 2, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(1, null, ListQueryMode.Ignore));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(2, null, ListQueryMode.Ignore));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 4 }, Enumerable.Range(0, 5).RemoveAll(3, null, ListQueryMode.Ignore));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 3 }, Enumerable.Range(0, 5).RemoveAll(4, null, ListQueryMode.Ignore));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 3, 4 }, Enumerable.Range(0, 5).RemoveAll(5, null, ListQueryMode.Ignore));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 3, 4 }, Enumerable.Range(0, 5).Remove(6, null, ListQueryMode.Ignore));
            EnumerableAssert.AreSequentialEqual(Enumerable.Empty <int>(), Enumerable.Repeat(0, 5).RemoveAll(0, null, ListQueryMode.Ignore));
            EnumerableAssert.AreSequentialEqual(Enumerable.Repeat(0, 5), Enumerable.Repeat(0, 5).RemoveAll(1, null, ListQueryMode.Ignore));
            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 3, 0, 1, 2, 3 }, Enumerable.Range(0, 5).Concat(Enumerable.Range(0, 5)).RemoveAll(4, null, ListQueryMode.Ignore));
            EnumerableAssert.AreSequentialEqual(new int[] { 1, 2, 3, 4, 1, 2, 3, 4 }, Enumerable.Range(0, 5).Concat(Enumerable.Range(0, 5)).RemoveAll(0, null, ListQueryMode.Ignore));
        }