Пример #1
0
        public void SerializeSynapseTest(int segmentindex, int synapseindex, double permanence)
        {
            Cell cell = new Cell(12, 14, 16, 18, new CellActivity());

            var distSeg1 = new DistalDendrite(cell, 1, 2, 2, 1.0, 100);

            cell.DistalDendrites.Add(distSeg1);

            var distSeg2 = new DistalDendrite(cell, 44, 24, 34, 1.0, 100);

            cell.DistalDendrites.Add(distSeg2);

            Cell preSynapticcell = new Cell(11, 14, 16, 28, new CellActivity());

            var synapse1 = new Synapse(cell, distSeg1.SegmentIndex, 23, 1.0);

            preSynapticcell.ReceptorSynapses.Add(synapse1);

            var synapse2 = new Synapse(cell, distSeg2.SegmentIndex, 27, 1.0);

            preSynapticcell.ReceptorSynapses.Add(synapse2);

            using (StreamWriter sw = new StreamWriter($"ser_{nameof(SerializeSynapseTest)}.txt"))
            {
                synapse1.Serialize(sw);
            }

            using (StreamReader sr = new StreamReader($"ser_{nameof(SerializeSynapseTest)}.txt"))
            {
                HtmSerializer2 ser = new HtmSerializer2();

                Synapse synapseT1 = ser.DeserializeSynapse(sr);

                Assert.IsTrue(synapse1.Equals(synapseT1));
            }
        }