void WithIntegerDataAndInt_ShouldBeEqual() { var data = new IntegerData(42); int number = 42; data.Should().Be(number); }
public void TestPredicate() { Console.WriteLine("--- TestPredicate ---"); IntegerData data = new IntegerData( delegate(int value) { if (value > 10) { return(true); } else { return(false); } }); data.Add(1); data.Add(5); data.Add(15); data.Add(20); foreach (int number in data) { Console.WriteLine("Number " + number); } }
void WithIntegerDataAndDouble_ShouldBeEqual() { var data = new IntegerData(42); double number = 42.0; data.Should().Be(number); }
void WithIntegerDataAndIntegerData_ShouldBeEqual() { var data1 = new IntegerData(42); var data2 = new IntegerData(42); data1.Should().Be(data2); }
public ActionResult Create(Comment comment) { if (ModelState.IsValid) { comment.Author = User.Identity.Name; cdb.Comments.Add(comment); cdb.SaveChanges(); Post post = pdb.Posts.Find(comment.RefferedPost); IntegerData idata = new IntegerData(); idata.Data = comment.ID; post.Comments.Add(idata); pdb.Entry(post).State = EntityState.Modified; pdb.SaveChanges(); //if is hitchhiker if (comment.Hitchhiker == true) { Hitchhiker hitch = new Hitchhiker() { Name = comment.Author, Phone = comment.PhoneNumber, PostID = comment.RefferedPost }; hdb.Hitchhikers.Add(hitch); hdb.SaveChanges(); } return(RedirectToAction("Details", "Post", new { id = post.ID })); } else { return(View(comment)); } }
void WithIntegerDataAndNullableLong_ShouldBeEqual() { var data = new IntegerData(42); long?number = 42; data.Should().Be(number); }
public async Task RecordIntegerDataAsync(string tileName, int value, CancellationToken cancellationToken) { var integerData = new IntegerData(value, DateTimeOffsetProvider.Now); await TilesRepository.InsertData(tileName, TileType.Integer, integerData.ToBsonDocument(), cancellationToken); await _eventDispatcher.PublishAsync(new NewDataEvent(new TileId(tileName, TileType.Integer), new { integerData.Value, integerData.AddedOn }), cancellationToken); }
public PaletteColorCustomizationVariable(int defaulIndex, string fileName) : this() { DefaultValue = new IntegerData { Value = defaulIndex }; PalettePathName = new StringData { Value = fileName }; }
public void Primitive_DontThrowIfEqual() { var expected = new IntegerData { Value = 1 }; var result = new IntegerData { Value = 1 }; DeepAssert.Equal(expected, result); }
static void Main(string[] args) { var a = new StringData("A"); var b = new IntegerData(1001); var dto = new SeriesDto(); dto.Data.Add(a); dto.Data.Add(b); var list = new HighchartsDto(); list.Series.Add(dto); DateTime time = list.Series[0].Data[0].CreatedTime; // time }
private static void CheckIntegers(List <IntegerData> integers, TypeSet t, Action CheckContents, ref ParameterType modifiedType) { IntegerData Integer1 = new IntegerData("int1", ParameterType.Parse("e051bfd8-d9d8-4f14-bd39-0ec1a9e9073b"), 456, 123); IntegerData Integer2 = new IntegerData("repeat", ParameterType.Parse("4427eb13-e799-4959-86a8-31a2dbd71b03"), 456, 123); IntegerData Integer3 = new IntegerData("repeat", ParameterType.Parse("e8aa3cef-8b60-4b08-bb8d-e0a9b2a2085e"), 1, 0); var a = Integer1; t.AddInteger(a); integers.Add(a); Assert.That(modifiedType, Is.EqualTo(a.TypeId)); modifiedType = null; CheckContents(); a = Integer2; t.AddInteger(a); integers.Add(a); Assert.That(modifiedType, Is.EqualTo(a.TypeId)); modifiedType = null; CheckContents(); a = Integer1; t.Remove(a.TypeId); integers.Remove(a); Assert.That(modifiedType, Is.EqualTo(a.TypeId)); modifiedType = null; CheckContents(); a = Integer3; t.AddInteger(a); integers.Add(a); Assert.That(modifiedType, Is.EqualTo(a.TypeId)); modifiedType = null; CheckContents(); IntegerData Integer2Replacement = new IntegerData("Integer2 replacement", ParameterType.Parse("4427eb13-e799-4959-86a8-31a2dbd71b03"), 234, -234); t.ModifyInteger(Integer2Replacement); integers[integers.IndexOf(Integer2)] = Integer2Replacement; Assert.That(modifiedType, Is.EqualTo(Integer2Replacement.TypeId)); modifiedType = null; CheckContents(); IntegerData Integer3Replacement = new IntegerData("replacement integer 3", ParameterType.Parse("e8aa3cef-8b60-4b08-bb8d-e0a9b2a2085e"), 1, 0); t.RenameType(Integer3.TypeId, Integer3Replacement.Name); integers[integers.IndexOf(Integer3)] = Integer3Replacement; Assert.That(modifiedType, Is.EqualTo(Integer3Replacement.TypeId)); modifiedType = null; CheckContents(); }
public void Primitive_ThrowIfDifferent() { var expected = new IntegerData { Value = 1 }; var result = new IntegerData { Value = 2 }; Assert.Throws <DeepAssertException>(() => { DeepAssert.Equal(expected, result); }); }
private static void Main() { var properties = new IntegerData(); properties.PropertyChanged += (s, e) => Console.Out.WriteLine($"Property {e.PropertyName} changed."); Console.Out.WriteLine($"properties.Value is {properties.Value}"); properties.Value = 2; Console.Out.WriteLine($"properties.Value is {properties.Value}"); properties.Value = 3; Console.Out.WriteLine($"properties.Value is {properties.Value}"); properties.Value = 3; Console.Out.WriteLine($"properties.Value is {properties.Value}"); properties.Value = 4; Console.Out.WriteLine($"properties.Value is {properties.Value}"); }
public override bool Parse(IFFFile.Node Source, ref int offset) { var toParse = Source.FindSiblingNodes("PCNT").ToList(); var pcnt = toParse.First(cur => cur.Type == "PCNT"); if (pcnt == null) { return(false); } var idx = 0; var size = pcnt.Data.ReadInt32(ref idx); if (toParse.Count != size - 1) { return(false); } foreach (var node in toParse.Where(cur => cur.Type == "XXXX")) { int readIdx = 0; string varName = node.Data.ReadAsciiString(ref readIdx); switch (varName) { case "variableName": VariableName = new StringData(node, ref readIdx); break; case "palettePathName": PalettePathName = new StringData(node, ref readIdx); break; case "defaultPaletteIndex": DefaultValue = new IntegerData(node, ref readIdx); break; default: break; } } return(true); }
public override async Task <IntegerData> GetDataAsync(CancellationToken cancellationToken) { try { var azureDevOpsHelper = new AzureDevOpsHelper(ConfigProvider, RootConfig); var codeCoverageDetails = await azureDevOpsHelper.GetCodeCoverageResultForLastGreenBuildAsync(cancellationToken); if (codeCoverageDetails == null) { return(IntegerData.NoUpdate()); } var linesCoverageData = codeCoverageDetails.CoverageData.First().CoverageStats.Single(x => x.Label == "Lines"); return(new IntegerData(linesCoverageData.Total, Status.OK)); } catch (Exception ex) { return(IntegerData.Error(ex.Message)); } }
public override bool Parse(IFFFile.Node Source, ref int offset) { int numVars = Source.Data.ReadInt32(ref offset); if (numVars != Source.Children.Count()) { throw new InvalidOperationException(string.Format("count in data stream({0}) does not match the number of nodes ({1})", numVars, Source.Children.Count())); } foreach (var item in Source.Children.Where(cur => cur.Type == "XXXX")) { var readOffset = 0; var varName = item.Data.ReadAsciiString(ref readOffset); switch (varName) { case "variableName": VariableName = new StringData(item, ref readOffset); break; case "minValueInclusive": MinValueInclusive = new IntegerData(item, ref readOffset); break; case "defaultValue": DefaultValue = new IntegerData(item, ref readOffset); break; case "maxValueExclusive": MaxValueExclusive = new IntegerData(item, ref readOffset); break; } } return(true); }
/// <summary> /// Populate a domain's various type data from xml /// </summary> /// <param name="domain">The domain to fill</param> /// <param name="root">The xml root node</param> private static void ReadTypes(DomainData domain, XElement root) { foreach (var a in root.Elements("DynamicEnumeration")) { DynamicEnumerationData typeData = new DynamicEnumerationData(a.Attribute("name").Value, Guid.Parse(a.Attribute("guid").Value)); domain.DynamicEnumerations.Add(typeData); } foreach (var a in root.Elements("Enumeration")) { var name = a.Attribute("name").Value; var guid = Guid.Parse(a.Attribute("guid").Value); var values = a.Elements("Value").Select(value => new EnumerationData.Element(value.Attribute("name").Value, Guid.Parse(value.Attribute("guid").Value))); EnumerationData typeData; if (a.Element("Default") != null) { if (a.Element("Default").Attributes("guid").Any()) { var def = Guid.Parse(a.Element("Default").Attribute("guid").Value); typeData = new EnumerationData(name, guid, values, def); } else if (a.Element("Default").Attributes("name").Any()) { var def = a.Element("Default").Attribute("name").Value; typeData = new EnumerationData(name, guid, values, def); } else { throw new Exception("Enumeration declared with a default node but no recognised default value"); } } else { typeData = new EnumerationData(name, guid, values); } domain.Enumerations.Add(typeData); } foreach (var a in root.Elements("Decimal")) { var aName = a.Attribute("name").Value; var guid = Guid.Parse(a.Attribute("guid").Value); var aMax = a.Attributes("max").Select <XAttribute, decimal?>(b => decimal.Parse(b.Value)).SingleOrDefault(); var aMin = a.Attributes("min").Select <XAttribute, decimal?>(b => decimal.Parse(b.Value)).SingleOrDefault(); var aDef = a.Attributes("default").Select <XAttribute, decimal?>(b => decimal.Parse(b.Value)).SingleOrDefault(); DecimalData typeData = new DecimalData(aName, guid, aMax, aMin, aDef); domain.Decimals.Add(typeData); } foreach (var a in root.Elements("Integer")) { var aName = a.Attribute("name").Value; var guid = Guid.Parse(a.Attribute("guid").Value); var aMax = a.Attributes("max").Select <XAttribute, int?>(b => int.Parse(b.Value)).SingleOrDefault(); var aMin = a.Attributes("min").Select <XAttribute, int?>(b => int.Parse(b.Value)).SingleOrDefault(); var aDef = a.Attributes("default").Select <XAttribute, int?>(b => int.Parse(b.Value)).SingleOrDefault(); IntegerData typeData = new IntegerData(aName, guid, aMax, aMin, aDef); domain.Integers.Add(typeData); } }
private void ParseNode(IFFFile.Node node, ITemplateRepository repo) { int offset = 0; var name = node.Data.ReadAsciiString(ref offset); switch (name) { case "gender": Gender = TryParseAssign(node, ref offset, Gender); break; case "niche": Niche = TryParseAssign(node, ref offset, Niche); break; case "species": Species = TryParseAssign(node, ref offset, Species); break; case "race": Race = TryParseAssign(node, ref offset, Race); break; case "acceleration": Acceleration = TryParseAssign(node, ref offset, Acceleration); break; case "speed": Speed = TryParseAssign(node, ref offset, Speed); break; case "turnRate": TurnRate = TryParseAssign(node, ref offset, TurnRate); break; case "animationMapFilename": AnimationMapFilename = TryParseAssign(node, ref offset, AnimationMapFilename); break; case "slopeModAngle": SlopeModAngle = TryParseAssign(node, ref offset, SlopeModAngle); break; case "slopeModPercent": SlopeModPercent = TryParseAssign(node, ref offset, SlopeModPercent); break; case "waterModPercent": WaterModPercent = TryParseAssign(node, ref offset, WaterModPercent); break; case "stepHeight": StepHeight = TryParseAssign(node, ref offset, StepHeight); break; case "collisionHeight": CollisionHeight = TryParseAssign(node, ref offset, CollisionHeight); break; case "collisionRadius": CollisionRadius = TryParseAssign(node, ref offset, CollisionRadius); break; case "movementDatatable": MovementDatatable = TryParseAssign(node, ref offset, MovementDatatable); break; case "postureAlignToTerrain": PostureAlignToTerrain = TryParseAssign(node, ref offset, PostureAlignToTerrain); break; case "swimHeight": SwimHeight = TryParseAssign(node, ref offset, SwimHeight); break; case "warpTolerance": WarpTolerance = TryParseAssign(node, ref offset, WarpTolerance); break; case "collisionOffsetX": CollisionOffsetX = TryParseAssign(node, ref offset, CollisionOffsetX); break; case "collisionOffsetZ": CollisionOffsetZ = TryParseAssign(node, ref offset, CollisionOffsetZ); break; case "collisionLength": CollisionLength = TryParseAssign(node, ref offset, CollisionLength); break; case "cameraHeight": CameraHeight = TryParseAssign(node, ref offset, CameraHeight); break; default: break; } }
static void Main(string[] args) { RC4Encryption rc4Server = new RC4Encryption(); RC4Encryption rc4Client = new RC4Encryption(); rc4Server.makeSBox("zhangyawei"); rc4Client.makeSBox("zhangyawei"); IntegerData idata = new IntegerData('a', 1, 5, 20, 30, 40, 50, 60); FloatData fdata = new FloatData(243.123123f, 32432.123); StringData sdata = new StringData("love"); EchoPack pack = new EchoPack(); pack._iarray = new IntegerDataArray(); pack._iarray.Add(idata); pack._iarray.Add(idata); pack._iarray.Add(idata); pack._farray = new FloatDataArray(); pack._farray.Add(fdata); pack._farray.Add(fdata); pack._farray.Add(fdata); pack._sarray = new StringDataArray(); pack._sarray.Add(sdata); pack._sarray.Add(sdata); pack._sarray.Add(sdata); pack._imap = new IntegerDataMap(); pack._imap.Add("123", idata); pack._imap.Add("223", idata); pack._fmap = new FloatDataMap(); pack._fmap.Add("523", fdata); pack._fmap.Add("623", fdata); pack._smap = new StringDataMap(); pack._smap.Add("723", sdata); pack._smap.Add("823", sdata); var now = DateTime.UtcNow; for (int i = 0; i < 1; i++) { var byteData = pack.__encode(); var binData = byteData.ToArray(); // for (int i = 0; i < binData.Length; i++) // { // System.Console.WriteLine((int)binData[i]); // } rc4Server.encryption(binData, binData.Length); rc4Client.encryption(binData, binData.Length); // for (int i = 0; i < binData.Length; i++) // { // System.Console.WriteLine((int)binData[i]); // } var v = new EchoPack(); int pos = 0; v.__decode(binData, ref pos); try { SimplePack pk = new SimplePack(10, "name", 100, null); pk.moneyTree = new MoneyTree(10001, 5, 5, 0, 0); var binMemory = pk.__encode().ToArray(); //序列化 SimplePack recvPK = new SimplePack(); int curPos = 0; recvPK.__decode(binMemory, ref curPos); System.Console.Write("success"); } catch (Exception e) { System.Console.Write("error"); } Client client = new Client(); client.Run(binData); } System.Console.WriteLine(DateTime.UtcNow - now); }
public Object serializeAnswerData(IntegerData data) { return(((int)data.Value).ToString()); }
void WithNullIntegerData_ShouldNotBeValid() { IntegerData data = (long?)null; data.IsValid().Should().BeFalse(); }
void WithUninitializedIntegerData_ShouldNotBeValid() { var data = new IntegerData(); data.IsValid().Should().BeFalse(); }
void WithValidIntegerData_ShouldBeValid() { var data = new IntegerData(42); data.IsValid().Should().BeTrue(); }
/*private void InternalParse(IFFFile.Node node, ITemplateRepository repo) * { * ParseData(node, repo, ParseData, _Logger); * }*/ private void ParseData(IFFFile.Node node, ITemplateRepository repo) { int offset = 0; var name = node.Data.ReadAsciiString(ref offset); switch (name) { case "objectName": ObjectName = TryParseAssign(node, ref offset, ObjectName); break; case "detailedDescription": DetailedDescription = TryParseAssign(node, ref offset, DetailedDescription); break; case "lookAtText": LookAtText = TryParseAssign(node, ref offset, LookAtText); break; case "snapToTerrain": SnapToTerrain = TryParseAssign(node, ref offset, SnapToTerrain); break; case "containerType": ContainerType = TryParseAssign(node, ref offset, ContainerType); break; case "containerVolumeLimit": ContainerVolumeLimit = TryParseAssign(node, ref offset, ContainerVolumeLimit); break; case "tintPallete": TintPallete = TryParseAssign(node, ref offset, TintPallete); break; case "slotDescriptorFilename": SlotDescriptorFileName = TryParseAssign(node, ref offset, SlotDescriptorFileName); break; case "arrangementDescriptorFilename": ArrangementDescriptorFileName = TryParseAssign(node, ref offset, ArrangementDescriptorFileName); break; case "appearanceFilename": AppearanceFileName = TryParseAssign(node, ref offset, AppearanceFileName); break; case "portalLayoutFilename": PortalLayoutFileName = TryParseAssign(node, ref offset, PortalLayoutFileName); break; case "clientDataFile": ClientDataFile = TryParseAssign(node, ref offset, ClientDataFile); break; case "collisionMaterialFlags": CollisionMaterialFlags = TryParseAssign(node, ref offset, CollisionMaterialFlags); break; case "collisionMaterialPassFlags": CollisionMaterialPassFlags = TryParseAssign(node, ref offset, CollisionMaterialPassFlags); break; case "collisionMaterialBlockFlags": CollisionMaterialBlockFlags = TryParseAssign(node, ref offset, CollisionMaterialBlockFlags); break; case "collisionActionFlags": CollisionActionFlags = TryParseAssign(node, ref offset, CollisionActionFlags); break; case "collisionActionPassFlags": CollisionActionPassFlags = TryParseAssign(node, ref offset, CollisionActionPassFlags); break; case "collisionActionBlockFlags": CollisionActionBlockFlags = TryParseAssign(node, ref offset, CollisionActionBlockFlags); break; case "scale": Scale = TryParseAssign(node, ref offset, Scale); break; case "gameObjectType": GameObjectType = TryParseAssign(node, ref offset, GameObjectType); ClientGameObjectType = GameObjectType.Value; break; case "sendToClient": SendToClient = TryParseAssign(node, ref offset, SendToClient); break; case "scaleThresholdBeforeExtentTest": ScaleThresholdBeforeExtentTest = TryParseAssign(node, ref offset, ScaleThresholdBeforeExtentTest); break; case "clearFloraRadius": ClearFloraRadius = TryParseAssign(node, ref offset, ClearFloraRadius); break; case "surfaceType": SurfaceType = TryParseAssign(node, ref offset, SurfaceType); break; case "noBuildRadius": NoBuildRadius = TryParseAssign(node, ref offset, NoBuildRadius); break; case "onlyVisibleInTools": OnlyVisibleInTools = TryParseAssign(node, ref offset, OnlyVisibleInTools); break; case "locationReservationRadius": LocationReservationRadius = TryParseAssign(node, ref offset, LocationReservationRadius); break; default: break; } }