Пример #1
0
        public void TestNoDuplicateErrorMessages()
        {
            var argsParser = new ArgsParser();

            argsParser.AddArgumentParser(new NonNegativeIntParser());
            argsParser.AddArgumentParser(new AnyOrderParser(argsParser));

            var ex = Assert.ThrowsAsync <ArgsParseFailure>(() => argsParser
                                                           .Parse <AnyOrder <NonNegativeInt, NonNegativeInt> >(ImmutableList.Create("1", "x")));

            Assert.AreEqual("did not recognize 'x' as a number", ex.Message);
            // this is how it used to be:
            Assert.AreNotEqual("did not recognize 'x' as a number, or did not recognize 'x' as a number", ex.Message);
        }
Пример #2
0
 public static ImmutableList <IArgumentTaker> MakeArguments(params IArgumentTaker[] arguments)
 => ImmutableList.Create(arguments);
Пример #3
0
 public void WhenSingleElement()
 {
     new DConsole.DebugSequenceDirectionData(sequence: ImmutableList.Create(
                                                 DConsole.Direction.Left
                                                 ));
 }
Пример #4
0
        public void RemoveRangeEnumerableTest()
        {
            var list = ImmutableList.Create(1, 2, 3);

            AssertExtensions.Throws <ArgumentNullException>("items", () => list.RemoveRange(null));

            ImmutableList <int> removed2 = list.RemoveRange(new[] { 2 });

            Assert.Equal(2, removed2.Count);
            Assert.Equal(new[] { 1, 3 }, removed2);

            ImmutableList <int> removed13 = list.RemoveRange(new[] { 1, 3, 5 });

            Assert.Equal(1, removed13.Count);
            Assert.Equal(new[] { 2 }, removed13);
            Assert.Equal(new[] { 2 }, ((IImmutableList <int>)list).RemoveRange(new[] { 1, 3, 5 }));

            Assert.Same(list, list.RemoveRange(new[] { 5 }));
            Assert.Same(ImmutableList.Create <int>(), ImmutableList.Create <int>().RemoveRange(new[] { 1 }));

            var listWithDuplicates = ImmutableList.Create(1, 2, 2, 3);

            Assert.Equal(new[] { 1, 2, 3 }, listWithDuplicates.RemoveRange(new[] { 2 }));
            Assert.Equal(new[] { 1, 3 }, listWithDuplicates.RemoveRange(new[] { 2, 2 }));

            AssertExtensions.Throws <ArgumentNullException>("items", () => ((IImmutableList <int>)ImmutableList.Create(1, 2, 3)).RemoveRange(null));
            Assert.Equal(new[] { 1, 3 }, ((IImmutableList <int>)ImmutableList.Create(1, 2, 3)).RemoveRange(new[] { 2 }));
        }
Пример #5
0
 public static ImmutableList <string> MakeNames(params string[] names)
 => ImmutableList.Create(names);
        internal static FSharpDiagnosticResult Error(string projectPath, string errorMessage)
        {
            var message = FSharpCompilationMessage.Error(projectPath, errorMessage);

            return(new FSharpDiagnosticResult(ImmutableList.Create(message)));
        }
Пример #7
0
 public void GetHashCodeVariesByInstance()
 {
     Assert.NotEqual(ImmutableList.Create <int>().GetHashCode(), ImmutableList.Create(5).GetHashCode());
 }
Пример #8
0
 /// <summary>
 /// Creates empty immutable list.
 /// </summary>
 /// <typeparam name="T">Type of list item</typeparam>
 /// <returns>empty list</returns>
 public static IList <T> EmptyList <T>()
 {
     return(ImmutableList.Create <T>());
 }
Пример #9
0
 /// <summary>
 /// Create single element immutable list.
 /// </summary>
 /// <typeparam name="T">Type of list item</typeparam>
 /// <param name="element">list element</param>
 /// <returns>single element list</returns>
 public static IList <T> Singleton <T>(T element)
 {
     return(ImmutableList.Create(element));
 }
 public FoodstuffSearchViewModel(Environment environment)
 {
     searched          = ImmutableList.Create <IFoodstuff>();
     Selected          = ImmutableList.Create <IFoodstuff>();
     this._environment = environment;
 }
Пример #11
0
 public static TextFieldInfo WithDescription(long workspaceId, string description)
 => new TextFieldInfo(workspaceId, ImmutableList.Create <ISpan>(new TextSpan(description)));
 public FullNameInternalSyntaxNode(IEnumerable <NameInternalNode> names)
     : base(ImmutableList.Create(names.Cast <InternalSyntaxNode>().ToArray()))
 {
 }
Пример #13
0
 public StarSystem()
 {
     bodies   = ImmutableList.Create <Body>();
     factions = new List <Faction>();
     stations = new List <Station>();
 }
Пример #14
0
 public void SetInfo(MappingSchema mappingSchema)
 {
     mappingSchema.SetConvertExpression <IEnumerable <T>, ImmutableList <T> >(
         t => ImmutableList.Create(t.ToArray()));
 }
Пример #15
0
        public void SetItem(TKey key, TValue value)
        {
            var oldList = this.Current;
            var newList = oldList.SetItem(key, value);

            if (oldList != newList)
            {
                var oldValue = oldList[key];
                this.Subject.OnNext(new DictionaryChangedNotification <TKey, TValue>(newList, NotifyCollectionChangedAction.Replace, ImmutableList.Create(new KeyValuePair <TKey, TValue>(key, oldValue)), ImmutableList.Create(new KeyValuePair <TKey, TValue>(key, value))));
            }
        }
 public MethodGremlinStep(string name, params object[] parameters) : this(name, ImmutableList.Create(parameters))
 {
 }
Пример #17
0
 static public Maybe <JustT> just(JustT j) =>
 new Maybe <JustT>
 {
     Just = ImmutableList.Create(j)
 };
Пример #18
0
 public HttpError(HttpStatusCode code, params string[] descriptions)
 {
     Code         = code;
     Descriptions = ImmutableList.Create <string>(descriptions);
 }
Пример #19
0
        public void Create_Test()
        {
            var col = ImmutableList.Create <int>(1, 2, 3, 4);

            Assert.AreEqual(4, col.Count);
        }
Пример #20
0
   public static ImmutableList <A> toImmutableList <A>(this Option <A> opt) =>
   opt.isSome
 ? ImmutableList.Create(opt.__unsafeGetValue)
 : ImmutableList <A> .Empty;
Пример #21
0
        public void ToImmutableListOfSameType()
        {
            var list = ImmutableList.Create("a");

            Assert.Same(list, list.ToImmutableList());
        }
Пример #22
0
 public static IImmutableList <IContextEntry> Normalize(this IReadOnlyList <IContextEntry> context) =>
 context.Aggregate(ImmutableList.Create <IContextEntry>(), (normalized, entry) =>
                   entry is TypeVariableDefinition t
Пример #23
0
        public void IsSynchronized()
        {
            ICollection collection = ImmutableList.Create <int>();

            Assert.True(collection.IsSynchronized);
        }
Пример #24
0
        private static IWittyerBnd CreateWittyerBnd([NotNull] string bndLine1, [NotNull] string bndLine2)
        {
            var variant = VcfVariant.TryParse(bndLine1,
                                              VcfVariantParserSettings.Create(ImmutableList.Create("normal"), GenomeAssembly.Grch37))
                          .GetOrThrowDebug();

            return(WittyerBndInternal.Create(variant, variant.Samples["normal"], WittyerType.TranslocationBreakend, Bins,
                                             BasepairDistance, PercentDistance, VcfVariant.TryParse(bndLine2,
                                                                                                    VcfVariantParserSettings.Create(ImmutableList.Create("normal"), GenomeAssembly.Grch37))
                                             .GetOrThrowDebug()));
        }
Пример #25
0
 public static ImmutableList <KeyValuePair <string, IArgumentTaker> > MakeOptions(
     params KeyValuePair <string, IArgumentTaker>[] options)
 => ImmutableList.Create(options);
Пример #26
0
 public void Add(TKey key, TValue value)
 {
     this.Subject.OnNext(new DictionaryChangedNotification <TKey, TValue>(this.Current.Add(key, value), NotifyCollectionChangedAction.Add, ImmutableList <KeyValuePair <TKey, TValue> > .Empty, ImmutableList.Create(new KeyValuePair <TKey, TValue>(key, value))));
 }
Пример #27
0
 public void WhenBadInEnd()
 {
     Assert.Throws <ArgumentException>(() => new DConsole.DebugSequenceDirectionData(sequence: ImmutableList.Create(
                                                                                         DConsole.Direction.Left, DConsole.Direction.Up, DConsole.Direction.Down,
                                                                                         DConsole.Direction.Right, DConsole.Direction.Right
                                                                                         )));
 }
Пример #28
0
        public void Remove(TKey key)
        {
            var oldList = this.Current;
            var newList = oldList.Remove(key);

            if (oldList != newList)
            {
                var oldValue = oldList[key];
                this.Subject.OnNext(new DictionaryChangedNotification <TKey, TValue>(newList, NotifyCollectionChangedAction.Remove, ImmutableList.Create(new KeyValuePair <TKey, TValue>(key, oldValue)), ImmutableList <KeyValuePair <TKey, TValue> > .Empty));
            }
        }
Пример #29
0
 public static ImmutableList <T> Compact <T>(this ImmutableList <T> list)
 {
     return(ImmutableList.Create <T>(list.ToArray()));
 }
Пример #30
0
        public void TestErrorMessageFromDeeplyNestedFailure()
        {
            var argsParser = new ArgsParser();

            argsParser.AddArgumentParser(new NonNegativeIntParser());
            argsParser.AddArgumentParser(new InstantParser());
            argsParser.AddArgumentParser(new AnyOrderParser(argsParser));
            argsParser.AddArgumentParser(new OptionalParser(argsParser));

            var ex = Assert.ThrowsAsync <ArgsParseFailure>(() => argsParser
                                                           .Parse <AnyOrder <Optional <NonNegativeInt>, Optional <Instant> > >(args: ImmutableList.Create("X", "Y")));

            Assert.AreNotEqual("too many arguments", ex.Message);
            Assert.AreEqual("did not recognize 'X' as a number, or did not recognize 'X' as a UTC-instant", ex.Message);
            Assert.AreEqual(new[]
            {
                new Failure(ErrorRelevanceConfidence.Default, "did not recognize 'X' as a number"),
                new Failure(ErrorRelevanceConfidence.Default, "did not recognize 'X' as a UTC-instant"),
                new Failure(ErrorRelevanceConfidence.Unlikely, "too many arguments")
            },
                            ex.Failures);
        }