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); }
public static ImmutableList <IArgumentTaker> MakeArguments(params IArgumentTaker[] arguments) => ImmutableList.Create(arguments);
public void WhenSingleElement() { new DConsole.DebugSequenceDirectionData(sequence: ImmutableList.Create( DConsole.Direction.Left )); }
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 })); }
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))); }
public void GetHashCodeVariesByInstance() { Assert.NotEqual(ImmutableList.Create <int>().GetHashCode(), ImmutableList.Create(5).GetHashCode()); }
/// <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>()); }
/// <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; }
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())) { }
public StarSystem() { bodies = ImmutableList.Create <Body>(); factions = new List <Faction>(); stations = new List <Station>(); }
public void SetInfo(MappingSchema mappingSchema) { mappingSchema.SetConvertExpression <IEnumerable <T>, ImmutableList <T> >( t => ImmutableList.Create(t.ToArray())); }
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)) { }
static public Maybe <JustT> just(JustT j) => new Maybe <JustT> { Just = ImmutableList.Create(j) };
public HttpError(HttpStatusCode code, params string[] descriptions) { Code = code; Descriptions = ImmutableList.Create <string>(descriptions); }
public void Create_Test() { var col = ImmutableList.Create <int>(1, 2, 3, 4); Assert.AreEqual(4, col.Count); }
public static ImmutableList <A> toImmutableList <A>(this Option <A> opt) => opt.isSome ? ImmutableList.Create(opt.__unsafeGetValue) : ImmutableList <A> .Empty;
public void ToImmutableListOfSameType() { var list = ImmutableList.Create("a"); Assert.Same(list, list.ToImmutableList()); }
public static IImmutableList <IContextEntry> Normalize(this IReadOnlyList <IContextEntry> context) => context.Aggregate(ImmutableList.Create <IContextEntry>(), (normalized, entry) => entry is TypeVariableDefinition t
public void IsSynchronized() { ICollection collection = ImmutableList.Create <int>(); Assert.True(collection.IsSynchronized); }
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())); }
public static ImmutableList <KeyValuePair <string, IArgumentTaker> > MakeOptions( params KeyValuePair <string, IArgumentTaker>[] options) => ImmutableList.Create(options);
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)))); }
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 ))); }
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)); } }
public static ImmutableList <T> Compact <T>(this ImmutableList <T> list) { return(ImmutableList.Create <T>(list.ToArray())); }
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); }