Exemplo n.º 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);
        }
Exemplo n.º 2
0
 public static ImmutableList <IArgumentTaker> MakeArguments(params IArgumentTaker[] arguments)
 => ImmutableList.Create(arguments);
Exemplo n.º 3
0
 public void WhenSingleElement()
 {
     new DConsole.DebugSequenceDirectionData(sequence: ImmutableList.Create(
                                                 DConsole.Direction.Left
                                                 ));
 }
Exemplo n.º 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 }));
        }
Exemplo n.º 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)));
        }
Exemplo n.º 7
0
 public void GetHashCodeVariesByInstance()
 {
     Assert.NotEqual(ImmutableList.Create <int>().GetHashCode(), ImmutableList.Create(5).GetHashCode());
 }
Exemplo n.º 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>());
 }
Exemplo n.º 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;
 }
Exemplo n.º 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()))
 {
 }
Exemplo n.º 13
0
 public StarSystem()
 {
     bodies   = ImmutableList.Create <Body>();
     factions = new List <Faction>();
     stations = new List <Station>();
 }
Exemplo n.º 14
0
 public void SetInfo(MappingSchema mappingSchema)
 {
     mappingSchema.SetConvertExpression <IEnumerable <T>, ImmutableList <T> >(
         t => ImmutableList.Create(t.ToArray()));
 }
Exemplo n.º 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))));
            }
        }
Exemplo n.º 16
0
 public MethodGremlinStep(string name, params object[] parameters) : this(name, ImmutableList.Create(parameters))
 {
 }
Exemplo n.º 17
0
 static public Maybe <JustT> just(JustT j) =>
 new Maybe <JustT>
 {
     Just = ImmutableList.Create(j)
 };
Exemplo n.º 18
0
 public HttpError(HttpStatusCode code, params string[] descriptions)
 {
     Code         = code;
     Descriptions = ImmutableList.Create <string>(descriptions);
 }
Exemplo n.º 19
0
        public void Create_Test()
        {
            var col = ImmutableList.Create <int>(1, 2, 3, 4);

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

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

            Assert.True(collection.IsSynchronized);
        }
Exemplo n.º 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()));
        }
Exemplo n.º 25
0
 public static ImmutableList <KeyValuePair <string, IArgumentTaker> > MakeOptions(
     params KeyValuePair <string, IArgumentTaker>[] options)
 => ImmutableList.Create(options);
Exemplo n.º 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))));
 }
Exemplo n.º 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
                                                                                         )));
 }
Exemplo n.º 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));
            }
        }
Exemplo n.º 29
0
 public static ImmutableList <T> Compact <T>(this ImmutableList <T> list)
 {
     return(ImmutableList.Create <T>(list.ToArray()));
 }
Exemplo n.º 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);
        }