public void VerfiyCustomTypeDescriptorMethods() { // Arrange var mockRecord = new Mock<IDataRecord>(); mockRecord.SetupGet(m => m["A"]).Returns(1); mockRecord.SetupGet(m => m["B"]).Returns(2); // Act ICustomTypeDescriptor record = new DynamicRecord(new[] { "A", "B" }, mockRecord.Object); // Assert Assert.AreEqual(AttributeCollection.Empty, record.GetAttributes()); Assert.IsNull(record.GetClassName()); Assert.IsNull(record.GetConverter()); Assert.IsNull(record.GetDefaultEvent()); Assert.IsNull(record.GetComponentName()); Assert.IsNull(record.GetDefaultProperty()); Assert.IsNull(record.GetEditor(null)); Assert.AreEqual(EventDescriptorCollection.Empty, record.GetEvents()); Assert.AreEqual(EventDescriptorCollection.Empty, record.GetEvents(null)); Assert.AreSame(record, record.GetPropertyOwner(null)); Assert.AreEqual(2, record.GetProperties().Count); Assert.AreEqual(2, record.GetProperties(null).Count); Assert.IsNotNull(record.GetProperties()["A"]); Assert.IsNotNull(record.GetProperties()["B"]); }
public void GetInvalidFieldValueThrows() { // Arrange var mockRecord = new Mock<IDataRecord>(); dynamic record = new DynamicRecord(Enumerable.Empty<string>(), mockRecord.Object); // Assert ExceptionAssert.Throws<InvalidOperationException>(() => { var value = record.C; }, "Invalid column name \"C\"."); }
public void GetFieldValueByIndexReturnsNullIfValueIsDbNull() { // Arrange var mockRecord = new Mock<IDataRecord>(); mockRecord.SetupGet(m => m[0]).Returns(DBNull.Value); dynamic record = new DynamicRecord(new[] { "A" }, mockRecord.Object); // Assert Assert.IsNull(record[0]); }
public void GetFieldValueByIndexAccessesUnderlyingRecordForValue() { // Arrange var mockRecord = new Mock<IDataRecord>(); mockRecord.SetupGet(m => m[0]).Returns(1); mockRecord.SetupGet(m => m[1]).Returns(2); dynamic record = new DynamicRecord(new[] { "A", "B" }, mockRecord.Object); // Assert Assert.AreEqual(1, record[0]); Assert.AreEqual(2, record[1]); }
void FixedUpdate() { if(ReplayManager.SessionActive && ReplayManager.StreamingIn) { if(lastPosition != transform.position) { DynamicRecord dr = new DynamicRecord(); dr.objectName = gameObject.name; dr.gameObject = gameObject; dr.frameNumber = TimeLine.GetFrameCount(); dr.animationName = "HELLO"; dr.animationFrameNumber = 0; dr.position = gameObject.transform.position; dr.rotation = gameObject.transform.rotation; ReplayManager.SaveState(dr); //Update last position lastPosition = transform.position; } } }
public virtual DynamicRecord AddString(DynamicRecord @string) { return(Add(_strings, @string)); }
public void VerifyPropertyDescriptorProperties() { // Arrange var mockRecord = new Mock<IDataRecord>(); mockRecord.SetupGet(m => m["A"]).Returns(1); mockRecord.Setup(m => m.GetOrdinal("A")).Returns(0); mockRecord.Setup(m => m.GetFieldType(0)).Returns(typeof(string)); // Act ICustomTypeDescriptor record = new DynamicRecord(new[] { "A" }, mockRecord.Object); // Assert var aDescriptor = record.GetProperties().Find("A", ignoreCase: false); Assert.IsNotNull(aDescriptor); Assert.IsNull(aDescriptor.GetValue(null)); Assert.AreEqual(1, aDescriptor.GetValue(record)); Assert.IsTrue(aDescriptor.IsReadOnly); Assert.AreEqual(typeof(string), aDescriptor.PropertyType); Assert.AreEqual(typeof(DynamicRecord), aDescriptor.ComponentType); Assert.IsFalse(aDescriptor.ShouldSerializeValue(record)); Assert.IsFalse(aDescriptor.CanResetValue(record)); }
public void SetAndResetValueOnPropertyDescriptorThrows() { // Arrange var mockRecord = new Mock<IDataRecord>(); mockRecord.SetupGet(m => m["A"]).Returns(1); // Act ICustomTypeDescriptor record = new DynamicRecord(new[] { "A" }, mockRecord.Object); // Assert var aDescriptor = record.GetProperties().Find("A", ignoreCase: false); Assert.IsNotNull(aDescriptor); ExceptionAssert.Throws<InvalidOperationException>(() => aDescriptor.SetValue(record, 1), "Unable to modify the value of column \"A\" because the record is read only."); ExceptionAssert.Throws<InvalidOperationException>(() => aDescriptor.ResetValue(record), "Unable to modify the value of column \"A\" because the record is read only."); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.kernel.impl.store.record.PropertyRecord readPropertyRecord(long id, org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException private PropertyRecord ReadPropertyRecord(long id, ReadableChannel channel) { // in_use(byte)+type(int)+key_indexId(int)+prop_blockId(long)+ // prev_prop_id(long)+next_prop_id(long) PropertyRecord record = new PropertyRecord(id); sbyte flags = channel.Get(); // 1 bool inUse = bitFlag(flags, Record.IN_USE.byteValue()); bool nodeProperty = !bitFlag(flags, Record.REL_PROPERTY.byteValue()); bool requireSecondaryUnit = bitFlag(flags, Record.REQUIRE_SECONDARY_UNIT); bool hasSecondaryUnit = bitFlag(flags, Record.HAS_SECONDARY_UNIT); bool usesFixedReferenceFormat = bitFlag(flags, Record.USES_FIXED_REFERENCE_FORMAT); record.RequiresSecondaryUnit = requireSecondaryUnit; record.UseFixedReferences = usesFixedReferenceFormat; long nextProp = channel.Long; // 8 long prevProp = channel.Long; // 8 record.NextProp = nextProp; record.PrevProp = prevProp; long primitiveId = channel.Long; // 8 if (primitiveId != -1 && nodeProperty) { record.NodeId = primitiveId; } else if (primitiveId != -1) { record.RelId = primitiveId; } if (hasSecondaryUnit) { record.SecondaryUnitId = channel.Long; } int nrPropBlocks = channel.Get(); Debug.Assert(nrPropBlocks >= 0); if (nrPropBlocks > 0) { record.InUse = true; } while (nrPropBlocks-- > 0) { PropertyBlock block = ReadPropertyBlock(channel); if (block == null) { return(null); } record.AddPropertyBlock(block); } int deletedRecords = ReadDynamicRecords(channel, record, PROPERTY_DELETED_DYNAMIC_RECORD_ADDER); if (deletedRecords == -1) { return(null); } Debug.Assert(deletedRecords >= 0); while (deletedRecords-- > 0) { DynamicRecord read = ReadDynamicRecord(channel); if (read == null) { return(null); } record.AddDeletedRecord(read); } if ((inUse && !record.InUse()) || (!inUse && record.InUse())) { throw new System.InvalidOperationException("Weird, inUse was read in as " + inUse + " but the record is " + record); } return(record); }
public void TestUpdate() { dynamic record = new DynamicRecord(); record.Id = 4; record.Email = "quux"; Database.Default.Users.Update(record); var element = _mockAdapter.Data.Element("Users").Elements().Where(e => e.Attribute("Id") != null && e.Attribute("Id").Value == "4").Single(); Assert.AreEqual("quux", element.Attribute("Email").Value); }
public virtual DynamicRecord AddPropertyKeyName(DynamicRecord name) { return(Add(_propertyKeyNames, name)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public <FAILURE extends Exception> void accept(RecordStore_Processor<FAILURE> processor, org.neo4j.kernel.impl.store.record.DynamicRecord record) throws FAILURE public override void Accept <FAILURE>(RecordStore_Processor <FAILURE> processor, DynamicRecord record) where FAILURE : Exception { processor.ProcessArray(this, record); }
public override void check(DynamicRecord record, CheckerEngine <DynamicRecord, ConsistencyReport_DynamicConsistencyReport> engine, RecordAccess records) { }
protected internal override void CheckDynamicLabel(RecordType type, RecordStore <DynamicRecord> store, DynamicRecord @string, RecordCheck <DynamicRecord, ConsistencyReport_DynamicLabelConsistencyReport> checker) { _report.forDynamicLabelBlock(type, @string, checker); }
public void onRecordNotInUse(DynamicRecord dynamicRecord, CheckerEngine <NodeRecord, ConsistencyReport_NodeConsistencyReport> engine) { engine.report().dynamicLabelRecordNotInUse(dynamicRecord); }
public virtual DynamicRecord AddArray(DynamicRecord array) { return(Add(_arrays, array)); }
public void TestUpdateByWithDynamicObject() { var mockDatabase = new MockDatabase(); dynamic database = CreateDatabase(mockDatabase); dynamic record = new DynamicRecord(); record.Id = 1; record.Name = "Steve"; record.Age = 50; database.Users.UpdateById(record); Assert.AreEqual("update [Users] set [Name] = @p1, [Age] = @p2 where [Users].[Id] = @p3".ToLowerInvariant(), mockDatabase.Sql.ToLowerInvariant()); Assert.AreEqual("Steve", mockDatabase.Parameters[0]); Assert.AreEqual(50, mockDatabase.Parameters[1]); Assert.AreEqual(1, mockDatabase.Parameters[2]); }
public virtual DynamicRecord AddLabelName(DynamicRecord name) { return(Add(_labelNames, name)); }
public virtual DynamicRecord AddRelationshipTypeName(DynamicRecord name) { return(Add(_relationshipTypeNames, name)); }
public virtual DynamicRecord AddSchema(DynamicRecord schema) { return(Add(_schemata, schema)); }
protected internal virtual void CheckSchema(RecordType type, RecordStore <DynamicRecord> store, DynamicRecord schema, RecordCheck <DynamicRecord, Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport> checker) { _report.forSchema(schema, checker); }
public void onRecordChainCycle(DynamicRecord record, CheckerEngine <NodeRecord, ConsistencyReport_NodeConsistencyReport> engine) { engine.report().dynamicRecordChainCycle(record); }
public virtual DynamicRecord AddNodeDynamicLabels(DynamicRecord array) { return(Add(_nodeDynamicLabels, array)); }
protected internal override void CheckDynamic(RecordType type, RecordStore <DynamicRecord> store, DynamicRecord @string, RecordCheck <DynamicRecord, Org.Neo4j.Consistency.report.ConsistencyReport_DynamicConsistencyReport> checker) { _report.forDynamicBlock(type, @string, checker); }
public override void accept(RecordStore_Processor processor, DynamicRecord record) { // Ignore }