public void Create() { FSharpSet <int> set1 = FSharpSet.Create(1, 2, 3); FSharpSet <int> set2 = new FSharpSet <int>(new[] { 1, 2, 3 }); Assert.AreEqual(set1, set2); }
public override int Serialize(ref byte[] bytes, int offset, FSharpSet <T> value) { if (value == null) { BinaryUtil.WriteInt32(ref bytes, offset, -1); return(4); } if (formatterLength != null) { // make fixed size. BinaryUtil.EnsureCapacity(ref bytes, offset, 4 + formatterLength.Value * value.Count); } var startOffset = offset; offset += BinaryUtil.WriteInt32(ref bytes, offset, value.Count); foreach (var item in value) { offset += formatter.Serialize(ref bytes, offset, item); } return(offset - startOffset); }
public Person(Gender gender, int age, FSharpSet <string> clothes, Sobriety sobriety) { this.gender = gender; this.age = age; this.clothes = clothes; this.sobriety = sobriety; }
public void Part3() { var person = new Person( gender: Gender.Male, age: 59, clothes: FSharpSet.Create("Jeans"), sobriety: Sobriety.Paralytic); var cost = GayBar.CostToEnter(person); Assert.AreEqual(FSharpChoice.Errors <decimal>("Too old!", "Smarten up!", "Sober up!"), cost); }
/// <summary> /// A MissionModel indicates some action the user wishes to occur, such as moving an entity to a target destination. /// </summary> /// <param name="action">what will happen</param> /// <param name="protagonist">who will do the action</param> /// <param name="startTime">when the mission can be started</param> /// <param name="start">entity target start state</param> /// <param name="finishTime">when the mission should be finished</param> /// <param name="destination">entity target finish state</param> /// <param name="lateFee">how important it is to finish on time</param> public MissionModel(int id, EnumMissionAction action, FSharpSet<int> doerIds, DateTime startTime, FSharpSet<int> targets, DateTime finishTime, Vector3D destination, float lateFee) { Id = id; Owner = String.Empty; Action = action; DoerIds = doerIds; StartTime = startTime; Targets = targets; FinishTime = finishTime; Destination = destination; LateFee = LateFee; }
protected override void Init() { base.Init(); list = ListModule.OfArray(new[] { 123, 2342355, 456456467578, 234234, -234281 }); set = SetModule.OfArray(new[] { 123, 2342355, 456456467578, 234234, -234281 }); record = new TestRecord( name: "John Doe", aref: FSharpOption <string> .Some("ok"), connections: "test"); du = DU2.NewC(DU1.NewB("test", 123)); sdu = SDU1.NewB("hello", 123); }
public void FSharpSetTest_0_Success() { var collection = new FSharpSet <int>(Enumerable.Empty <int>()); var target = this.CreateTarget <FSharpSet <int> >(); using (var buffer = new MemoryStream()) { target.Pack(buffer, collection); buffer.Position = 0; var unpacked = target.Unpack(buffer); buffer.Position = 0; Assert.That(unpacked.ToArray(), Is.EqualTo(collection.ToArray())); } }
public void DeepCopyTests_FSharp_Collections() { // F# list { var original = FSharpList <int> .Empty; var copy = (FSharpList <int>) this.fixture.SerializationManager.DeepCopy(original); Assert.Equal(original, copy); } { var original = ListModule.OfSeq(new List <int> { 0, 1, 2 }); var copy = (FSharpList <int>) this.fixture.SerializationManager.DeepCopy(original); Assert.Equal(original, copy); } // F# set { var original = new FSharpSet <int>(new List <int>()); var copy = (FSharpSet <int>) this.fixture.SerializationManager.DeepCopy(original); Assert.Equal(original, copy); } { var elements = new List <int>() { 0, 1, 2 }; var original = SetModule.OfSeq(elements); var copy = (FSharpSet <int>) this.fixture.SerializationManager.DeepCopy(original); Assert.Equal(original, copy); } // F# map { var original = new FSharpMap <int, string>(new List <Tuple <int, string> >()); var copy = (FSharpMap <int, string>) this.fixture.SerializationManager.DeepCopy(original); Assert.Equal(original, copy); } { var elements = new List <Tuple <int, string> >() { new Tuple <int, string>(0, "zero"), new Tuple <int, string>(1, "one") }; var original = MapModule.OfSeq(elements); var copy = (FSharpMap <int, string>) this.fixture.SerializationManager.DeepCopy(original); Assert.Equal(original, copy); } }
public void Set() { FSharpSet <int> l = SetModule.OfSeq(new List <int> { 1, 2, 3 }); string json = JsonConvert.SerializeObject(l, Formatting.Indented); Assert.AreEqual(@"[ 1, 2, 3 ]", json); FSharpSet <int> l2 = JsonConvert.DeserializeObject <FSharpSet <int> >(json); Assert.AreEqual(l.Count, l2.Count); CollectionAssert.AreEquivalent(l, l2); }
public ObjectPresent(object obj, FSharpSet <Guid> majorsStillOwedValue, FSharpSet <Guid> minorsStillOwedValue) { Obj = obj; MajorsStillOwedValue = majorsStillOwedValue; MinorsStillOwedValue = minorsStillOwedValue; }
public override void Write(Utf8JsonWriter writer, FSharpSet <T> value, JsonSerializerOptions options) => writer.SerializeToArray(value, options);
// convenience constructor often only one actor is involved public MissionModel(int id, EnumMissionAction action, int doerId, DateTime startTime, FSharpSet<int> targets, DateTime finishTime, Vector3D destination, float lateFee) : this(id, action, new FSharpSet<int>(new[] { doerId }), startTime, targets, finishTime, destination, lateFee) { }
public void AddSelectedTask(int id) { _indSelectedTasks.OnSet(); _selectedTasks = _selectedTasks.Add(id); }
public void RemoveSelectedEntity(int id) { _indSelectedEntities.OnSet(); _selectedEntities = _selectedEntities.Remove(id); }
private Set1(FSharpSet <T> ofAtLeastOne) { Contents = ofAtLeastOne; }
public void SetSelectedEntity(int id) { _indSelectedEntities.OnSet(); _selectedEntities = new FSharpSet<int>(new[] { id }); }
public WorldModel Put(FSharpSet<EntityModel> entities, EntityModel on) { return new WorldModel(Entity, Task, Plan, Holding.Add(on, SetModule.Union(Holding[on], entities)), Doing, BelongsTo); }
public void Create() { FSharpSet<int> set1 = FSharpSet.Create(1, 2, 3); FSharpSet<int> set2 = new FSharpSet<int>(new[] { 1, 2, 3 }); Assert.AreEqual(set1, set2); }
public void SetSelectedTask(int id) { _indSelectedTasks.OnSet(); _selectedTasks = new FSharpSet<int>(new[] { id }); }
public void RemoveSelectedMission(int id) { _indSelectedMissions.OnSet(); _selectedMissions = _selectedMissions.Remove(id); }
public void AddSelectedMission(int id) { _indSelectedMissions.OnSet(); _selectedMissions = _selectedMissions.Add(id); }
public void SetSelectedMission(int id) { _indSelectedMissions.OnSet(); _selectedMissions = new FSharpSet<int>(new[] { id }); }
public void CreateMission(int id, EnumMissionAction action, FSharpSet<int> doerIds, DateTime startTime, FSharpSet<int> targets, DateTime finishTime, Vector3D destination, float lateFee) { Send(new CreateMission(new MissionModel(id, action, doerIds, startTime, targets, finishTime, destination, lateFee))); }
public Person(Gender gender, int age, FSharpSet<string> clothes, Sobriety sobriety) { this.gender = gender; this.age = age; this.clothes = clothes; this.sobriety = sobriety; }
protected override IEnumerator <T> GetSourceEnumerator(FSharpSet <T> source) { return(((IEnumerable <T>)source).GetEnumerator()); }
public WorldModel Put(FSharpSet <EntityModel> entities, EntityModel on) { return(new WorldModel(Entity, Task, Plan, Holding.Add(on, SetModule.Union(Holding[on], entities)), Doing, BelongsTo)); }
public void RemoveSelectedTask(int id) { _indSelectedTasks.OnSet(); _selectedTasks = _selectedTasks.Remove(id); }
public SetProxy(FSharpSet <T> set) => (FSharpSet, HashSet) = (set, new Lazy <HashSet <T> >(() => new HashSet <T>(FSharpSet), LazyThreadSafetyMode.ExecutionAndPublication));
public void AddSelectedEntity(int id) { _indSelectedEntities.OnSet(); _selectedEntities = _selectedEntities.Add(id); }